• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing a scriplet value from a page w/ a FORM

 
Nelson Nadal
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • 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.....
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • 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.
 
krithika desai
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once done using a attribute use sessio.removeAttribute to remove it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks for your responses I appreciate your prompt replies.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!