• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Using the variables of same JSP page

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have got a JSP page .
It has got a textfield.
During run time the textfield is set to some value. I want to know if there is any way of using the value of the textfiled in the same JSP page.

I have tried
String flag=(flag)request.getParameter("nameofthetextfield")

In the action of the form I have put the same jsp page where the textfield resides.

But all the time I get a null value in flag though the textfield displays the changed value.

Any idea how I can extract the value of the textfield
 
Jibesh Patra
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I have done a typing mistake in the above post please bear with me.

String flag=(flag)request.getParameter("nameofthetextfield")
will be
String flag=(String)request.getParameter("nameofthetextfield")
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can always edit your posts by clicking on the icon.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getParameter is used for retrieving post parameters or query string parameters from the client.

I'm not completely sure what you mean by "use the value in the same JSP".
Can you explain further?
 
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
No, you cannot. The JSP is executed on the server before the page is sent to the browser where the user can fill in the field.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To clarify a little further: Because all JSP tags operate on the page before it's sent to the browser, you can't access values entered at runtime in JSP code.

However, because JavaScript runs in the browser itself, you can use JavaScript code to access values entered at runtime.
 
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
You might find this article helpful.
 
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic