File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issue with request.setAttribute(String,obj)

 
Ren Sha
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have 2 servlet pages and 1HTML page


HTML: Biodata form, using POST method
Servlet1:POST method , redirecting to Servlet2
Servlet2:need to access some values from the Biodata form


I'm using request.setAttribute(Str,obj) on Servlet1 and request.getAttribute() on Servlet2. I dont want to use RequestDispatcher or session.
What i understand is i can access the values(Str) if i'm using it only in consecutive page.
But I'm getting "null" as result.

Can anyone please help me in this
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you redirect, a new request is made and so any scoped variables placed on the original request are lost. Either use the session, or place the values on the URL as request parameters.

And before you say "I don't want to use the session" again, what's the valid reason for that?
 
Ren Sha
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just want to pass this value only in one page, so i was wondering is there any way i can do it without using session or RequestDispatcher.

I'm new to Java and dont have much idea about it till now so just trying to understand it with doing some examples.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said, if it's a text value you could also pass it as a request parameter on the URL.

Other possibilities include storing the data in a database to be retrieved on the next page.
 
Ren Sha
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic