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

how to get result of requet.getAttribute() from jsp?

 
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, good day , if i have page1.jsp , and it have request.setAttribute("resultTest"), but when i click on submit button, which act to fire form.action=page2.jsp , and in page2.jsp , why i can't get the result of request.getAttribute("resultTest") ?

can do i resolve this problem ? means i want to use request.getAttribute rather than session.getAttribute() ...thank you for guidance
 
Sheriff
Posts: 67753
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
Once the response has been sent to the browser, the request goes out of scope.
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for reply, Bear Bibeault , mind to elaborate more on this ?

can i do something on this in order to use request.getAttribute()?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My understanding is that your first jsp presents the user with a form. Pressing the submit button then has the second jsp as its action...

These 2 jsp's are processed as seperate requests and as such do not
share the same request object.

You can use sessions, but you could also just submit the data you want
to go to the second jsp as a parameter in the POST.
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks, Alwyn Schoeman for explain, but due to the parameter passing are list , so i need to apply either session or request.setAttribute("myList"), but it good if i send the list over to page2.jsp with fresh list, in order to avoid keep other previous list, of course i can use session.removeAttribute(), but request.setAttribute will save few line of code like validation and so on

so conclusion, we can't use request.getAttribute() in page2.jsp if we forward setAttribute from page1.jsp ...thank you for guidance anyway

if we use response.sendRedirect() , would it help ?
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi


You have to go for JSP Forward tag. As it is working on server side and doesn't create new request object, you will not lose your data.
You will not see URL changing from page1 to page2.
 
Bear Bibeault
Sheriff
Posts: 67753
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
Using a forward is not appropriate for this case.
 
reply
    Bookmark Topic Watch Topic
  • New Topic