Reading Variable from JSP and pass to servlet

helloi have a servlet page which transfers data to a jsp page. The jsp displays the data only. Now i want to read a string from a jsp page and then pass it to the servlet.How can i do it?thnks
[220 byte] By [pipsua] at [2007-11-27 6:05:10]
# 1
If you mean when the user pushes the "submit" button, send the information along with the request, put a <input type="hidden"> field on the page with the info you want to send.Communication JSP -> Servlet can only done via http requests and request parameters.
evnafetsa at 2007-7-12 16:50:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hello

I am having problems with what you have adviced me.

I have a variable called patronId on a jsp page. I want to pass it to a servlet which will then call the database class and query values.

How can i insert the patronId and the form can remember it cause I have tried this....

String patronId = ""+1234 ;

out.println("<input type=\"hidden\" name=\"bookId\" value=\"+bookId+\" size=\"25\">") ;

hope u understood got me

pipsua at 2007-7-12 16:50:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Let's use the code highlighter (don't you have this in your editor / IDE?):out.println("<input type=\"hidden\" name=\"bookId\" value=\"+bookId+\" size=\"25\">") ;See what's wrong with it.
BalusCa at 2007-7-12 16:50:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
hellothis is working fine: out.println("<input type=\"hidden\" name=\"bookId\" value=\"+bookId+\" size=\"25\">") ;works finethnks
pipsua at 2007-7-12 16:50:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
This should work..out.println("<input type='hidden' name='bookId' value='"+bookId+"' size='25'>") ;
venkksa at 2007-7-12 16:50:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

> hello

>

> this is working fine: out.println("<input

> type=\"hidden\" name=\"bookId\" value=\"+bookId+\"

> size=\"25\">") ;

>

> works fine

>

> thnks

I guess you didn't understand me. Look to the difference between the following two statements:

out.println("<input type=\"hidden\" name=\"bookId\" value=\"+bookId+\" size=\"25\">") ;

and

out.println("<input type=\"hidden\" name=\"bookId\" value=\""+bookId+"\" size=\"25\">") ;

In the first you're handling the bookId variable as String, in the second it will use the actual value of bookId.

BalusCa at 2007-7-12 16:50:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...