• Post Reply Bookmark Topic Watch Topic
  • New Topic

setting as request Attribute...

 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,..

I am just curious to know if you can set a Request attribute with href onClick..

say for example i have a javabean 'User' and in a JSP i display all the users and when you click on any user i call another program and pass the
User bean class,.. Is this possible..??

I know one other way would be to pass the user id as a 'request parameter'
and then using a query, create the bean class again from the user id..

Your opinions on this...
Appreciate your help
Thanks

PS: i am not an expert in javascript..
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, it is possible to pass request parameters even with href.
just append the parameters to the URL as a query string.



The above code can be generated directly by the Servlet/JSP and the Servlet/JSP mentioned in the 'href' can access all the parameters.

Another way is to capture which link has been clicked using Javascript and then appending the query string in a Javascript method before submitting to a Servlet/JSP

[Edited to remove smilies]
[ August 30, 2005: Message edited by: Neeraj Dheer ]
 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks

but that was not what i was asking about.. In my post i did say
what you said:
(from my previous post)
I know one other way would be to pass the user id as a 'request parameter'

I was asking about setting a request Attribute rather than request parameter

something like request.setAttribute("user",user) upon href onClick..

Thanks anyway.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
onClick events take place on the client's machine (in the browser).
setAttribute(..) is a Java method that takes place on the server.

The only way for you to do anything on the server from a browser is via an HTTP request - period. This is a crucial concept to understand if you are going to develop for the web - regardless of the technology you're using.
[ August 30, 2005: Message edited by: Ben Souther ]
 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OOPS ...

i think i am presently out of my sense..
I don't know what i was thinking about..

Thanks anyway Ben
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!