Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Change a request parameter  RSS feed

 
Paul Duer
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
As usual I have to preface my question with I am sorta a newbie, so be gentle!
Anyway the question is. I am taking the request object from a JSP and reading the parameters in a Servlet. I am then performing some basic logic on it(I know know, should use a bean but it's real basic), using the setAttribute to add a Vector object to the request, and then forwarding onto another JSP.
The question is, I use some parameters that I don't add the vector, that I read from the request with getparameter. Is it possbile to change the value of the string object and replace that string onto that request object parameter?
I was kinda tryin to go for a simple MVC model with the Servlet acting as traffic cop for the JSPs. But I would really like to be able to adjust some of the request parameters in the Servlet to suit my needs. :roll:
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul
You can't change the request parameters but you can add to the request attributes. You can use setAttribute to store the object then use request dispatcher to send the request (and your new attribute) to the JSP.
The cool thing is that the request attributes are reset between requests so you don't have to worry about clearing them out yourself. On the other hand if the object is something you're going to use again in another request then use the session to store the object and you can access it in resource in the app.
hope that helps
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!