File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes attribute from jsp to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "attribute from jsp to servlet" Watch "attribute from jsp to servlet" New topic
Author

attribute from jsp to servlet

Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 104

Hello.

I want to pass an attribute from a jsp to servlet

I have tried


request.setAttribute("att", vector); in the jsp

the in the servlet

vector (Verctor)request.getAttribute("att");

but it doesn�t work

Does it only works from servlet to jsp and not in the other way?

Thanks
Sudarshan Chakrabarty
Ranch Hand

Joined: Apr 10, 2008
Posts: 38
It works both way i.e. servlet -> jsp and jsp -> servlet.
You can access the attributes in both the places.
Can you publish your jsp and servlet code?
arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3223
Are you doing it within the same request? If your request goes out of scope, you attribute won't be available.


Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

Originally posted by Sudarshan Chakrabarty:
It works both way i.e. servlet -> jsp and jsp -> servlet.
You can access the attributes in both the places.
No, you can't.

Once the response is sent to the client, the request that generated the first JSP goes out of scope. Any attributes set on that request go away with it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: attribute from jsp to servlet