• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding about sending request attributue from jsp to servlet  RSS feed

 
siva prakashmahendran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to set request attribute in jsp and getting that attribute in servlet
Here is my code sippets
In jsp
<% Vector vt1 = new Vector();
request.setAttribute("vt1" ,vt1);
%>
In servlet
Vector vt = new Vector();
vt = (Vector) request.getAttribute("vt1" );
I got the following Exception
java.lang.NullPointerException


 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the request to the servlet is a new request--not the one that rendered the JSP.
 
siva prakashmahendran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please give me the solution for this problem
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either submit the value in a form (the normal way to get values from a JSP to a servlet), or put it in session.
 
siva prakashmahendran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes david I done by sending form elements to servlet
Instead of going to sessionobject
request object is thread safe right thats why i choose one
Any way thanks for valuable help man
 
sachin burange
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Siva i guess request attribute normally comes from servlet to jsp.
We are trying here in reverse i.e from jsp to servlet.

anyone comments on this ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sachin is correct. This is a very odd and unusual thing to want to do. Why are you doing it?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!