• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

attribute from jsp to servlet

 
Ranch Hand
Posts: 111
Eclipse IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Author
Posts: 3473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you doing it within the same request? If your request goes out of scope, you attribute won't be available.
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic