• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

adding a new value to the request...

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I need to add a new value to the request object. I am using the
request.setAttribute(String,Object)
and then using request dispatcher to forward the request from a servlet to another servlet,
but the added attributes dont seem to forwarded,
how do forward an request object along with the newly added value?
Thanks
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In general redirecting requests in this way does not pass the attributes. Why not put your values in the session, and retrieve them in the destination servlet?
 
Bala Krishniah
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is the code to loginServlet is already created and we dont want to touch the code. In LoginServlet we are also creating a brand new session object. From DataServlet I am passing two values in the request which is already there. But I also need to add one more brand new one into the request, before I forward to the LoginServlet.
One thing I can to is call the DataServlet by passing all the three values in the request and directly forward this to the LoginServlet.
But I have to change all the links in many places. So I thout I could just add here before forwarding the request.
Is there a way?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Personally I strongly disagree with putting transient information on the Session object.
The first reason is that sessions are generally pretty heavy and you end up packing it with extra data that sits on the server if the session isn't invalidated or until the server cleans it up.
Secondly it can cause unexpected application behaviour if the client uses the back button or jumps several pages backwards.
Which app server are you using? It might be a bug in their implementation of setAttribute()
 
Bala Krishniah
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using VAJ with WebSphere....
I am doing,
request.setAttribute("action","LOGIN");
request.setAttribute("type","name");
RequestDispatcher reqDispatcher = this.getRequestDispatcher("webapp/LoginServlet");
reqDispatcher.forward(request, response);

But the attibutes action and type are not being passed.
What am I doing wrong?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic