• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Adding a parameter to a request

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Firstly let me appologise for the amount of questions im asking......
Can anyone tell me how to add a parameter to a HttpServletRequest. Say for example if i wanted to add a parameter to it and then dispatch it off by forwarding it to another servlet. Do i use something like setAttribute???
What exactly does an attribute mean, is an attribute the same as a parameter etc as they are both stored in the body when using POST???
 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes David u r absolutely correct..
U can very well use setAttribute ro store the paramter...

And this is same like the attribute in <html>.
 
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,
Attributes are Objects, parameters are Strings.
kktec
SCJP, SCWCD, SCJD
"The journey is the reward."
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi david,
other than adding some attributes to your request object, i suggest that you also try to add some attributes to your HttpSession becasue using session to store the "shared object" between jsp and servlet is an important method too.
Have fun, hope this help.
 
David Swan
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cheers everybody thanks for the help...
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpServletRequest parameters can not be set. They can only be got.
The only thing that can be set on a request is attributes
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,

HttpServletRequest parameters can not be set. They can only be got.


That statement is not entirely true. You are partially right because we cannot set request parameters within a jsp/servlet with a call like request.setParameter(name, value). However, when we include/forward a page in JSP we can set addtional request parameters. For eg:

Now test1.jsp can retrieve this parameter with request.getParameter("temp"). The container is responsible for passing these run time parameters to the included/forwarded page. It usually appends them as query string to the URL and includes/forwards to the specified page.
Ciao,
GSS
 
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic