This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to add data in request object and pass it to next page?

 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am in JSP page a.jsp, its has one hyper link on it, My intention is I have to some data in request object and pass it to next page ,

when I click on the hyperlink, I should navigate to Next JSP b.jsp, there I will get the same data
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No can do. The two JSPs exist in separate requests so they cannot share data. The request that generates the first HTML page from the first JSP goes out of scope as soon as the response is sent to the browser. Any scoped variables created on that request go by-by with the request.

If you want to preserve some data across requests you'll either need to store it in the session, or carry it on the page as hidden values (suitable only for text strings).
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

request object 's scope belongs to Server and hyperlink is just a link in Client browser. So it is possible only when you pass request object's value in the hyperlink as query string .

<!a href="/web/app?value=one"> like this
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
carry it on the page as hidden values (suitable only for text strings).


it is really very interesting ,could please give some code or explain in details will help me lot
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<input type="hidden" name="whatever" value="Some string value"/>


this I have to use in first JSP or then next JSP page??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think about it for a minute. It acts just like any other form field.
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



I have tried to use Hidden Fields values outside of form bean and checked the request parameters in the next JSP page ,but I cant fins that variable,

Is the right way of using ??
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hidden fields are still associated with a form--that's how they get submitted.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As mentioned, hidden fields are associated with the form. So, put your hidden fields declaration within your form tag. You currently have it outside the form tag.

jacob deiter wrote:


I have tried to use Hidden Fields values outside of form bean and checked the request parameters in the next JSP page ,but I cant fins that variable,

Is the right way of using ??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic