• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing a scriplet value from a page w/ a FORM

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to pass a variable value to the next JSP page BUT that variable value is not included in the FORM. Ex:
<scriplet here.....
String v = "java";
</scriplet>
<FORM... METHOD="POST"...
<INPUT TYPE="TEXT" ....
<INPUT TYPE="SUBMIT" ...
</FORM>

Now I want to pass the value of String variable v to next page (based on ACTION of course>, how will I do that?
Do I make a JavaScript pass that to JS function and put it in a hidden type when submitted?
Im thinking of putting it as attribute of a request or session , but it can't because there is no way of dispatching a request because Im submitting a form and not forwarding a page. Please help Thanks.....
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Im thinking of putting it as attribute of a request or session , but it can't because there is no way of dispatching a request because Im submitting a form and not forwarding a page.


You can store the value in session scope and it will be available if the FORM is submitted.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put in session if u *really* have to. Otherwise use the hidden fields. Why do u want to increase the lifetime of a variable?
You dont need to do it through JS if the value can be obtained from within a scriplet.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once done using a attribute use sessio.removeAttribute to remove it.
 
Sheriff
Posts: 67746
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
Why do feel that you cannot just add the value to the form as a hidden field?
bear
 
Nelson Nadal
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your responses I appreciate your prompt replies.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic