• 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

capturing variable in "value" field of the form

 
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

this code will provide default text in the textfield as "enter query"

If I want this value to be provided by java variable input_text, where input_text has value of "enter query"




In the first instance, default value for the input text field will become


while in second instance value=enter query , will this be valid ?

I tried it both ways and in the text field, I got "null".

How to capture value dynamically ?

thanks
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your first step should be to find out which of those things generates the HTML you want. (Use "View Page Source" in your browser.) If none of them do, then make the appropriate changes or ask a question here in which you post the desired HTML as well as your proposed JSP code.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you use like this


you most make sure that input_text is not null,and its instance exist pageScope requestScope...otherwise that show null.

eg:



after save input_text in requestScope ,you can use it in jsp page like
one way:

anthoer way using el:
 
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

hexin orsen wrote:you most make sure that input_text is not null,and its instance exist pageScope requestScope


Not correct. When using old-fashioned scriptlet expressions, the variable must be a scripting variable, not a scoped variable.

after save input_text in requestScope ,you can use it in jsp page like


Again, not correct. Scoped variables are accessed via the modern EL, not out-moded scriptlets.

anthoer way using el:


When using scoped variables -- which this user is most likely not doing -- the EL must be used (or complicated scriptlet crap that shouldn't be used).
 
hexin orsen
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
first thanks Bear criticism,i did not communicate their ideas clearly and had several mistakes.

hexin orsen wrote:
you most make sure that input_text is not null,and its instance exist pageScope requestScope

Not correct. When using old-fashioned scriptlet expressions, the variable must be a scripting variable, not a scoped variable.



i say that input_text is servlet to jspcode.but it can be initialized in jsp



if you do this ,input_text will aotu-save in current pageSope;

after save input_text in requestScope ,you can use it in jsp page like

Again, not correct. Scoped variables are accessed via the modern EL, not out-moded scriptlets.



el get parameter's values in pageScope or requestScope ..... even now , you can initialize :input_text = null;
that is correct.

 
Bear Bibeault
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

hexin orsen wrote:i say that input_text is servlet to jspcode.but it can be initialized in jsp


Scriptlet variables have nothing to do with servlets and are not carried from servlets to JSP. You are confusing scoped variables and scripting variables.

if you do this ,input_text will aotu-save in current pageSope;


Again, incorrect. Nothing "auto-saves" to page scope or anywhere else.

el get parameter's values in pageScope or requestScope ..... even now , you can initialize :input_text = null;
that is correct.


I'm not sure what you are trying to say here, but the poster is not using the EL, but scriptlet expressions (even though their use is discouraged these days).
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

nirjari patel wrote:

How to capture value dynamically ?



What do you mean by dynamic here ? if you store the value "enter query" in JSP scriplet variable and use it in same JSP , is that dynamic ? if the text value is generated out of some logic , then it can be said dynamic and this logic is more appropriate to be coded inside servlet or helper class and exposed as scoped variable to be used in JSP.
reply
    Bookmark Topic Watch Topic
  • New Topic