Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Servlets---Passing parameters using input type=hidden

Status
Not open for further replies.

Climax11

Programmer
Mar 30, 2002
2
US
I'm new to JAVA and even newer to servlets...here's my problem.

I am passing an author and a quote from one servlet to another using the following code...

out.println( &quot;<input type=hidden name=sAuthor value=&quot; + sAuthor + &quot;>&quot; );
out.println( &quot;<input type=hidden name=sQuote value=&quot; + sQuote + &quot;>&quot; );

I am receiving the author & quote in the second servlet using the following code...

String sAuthor = request.getParameter( &quot;sAuthor&quot; );
String sQuote = request.getParameter( &quot;sQuote&quot; );

The problem is that for some reason I am only getting the first word of the author, and the first word of the quote and everything else is getting truncated.

Any ideas on what I am doing wrong?

Thanks in advance,
Climax11
 
You need to wrap the values in quotes:

out.println( &quot;<input type=hidden name=sAuthor value='&quot; + sAuthor + &quot;'>&quot; );
out.println( &quot;<input type=hidden name=sQuote value='&quot; + sQuote + &quot;'>&quot; );

If single quotes don't work, use escaped double quotes:

out.println( &quot;<input type=hidden name=sAuthor value=\&quot;&quot; + sAuthor + &quot;\&quot;>&quot; );
out.println( &quot;<input type=hidden name=sQuote value=\&quot;&quot; + sQuote + &quot;\&quot;>&quot; );

 
Thanks meandandale.....the single quotes did the trick!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top