Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reverse2Servlet

 
Ronald Schindler
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, so I'm trying to get back on the trail and for the life of me I cannot figure out how to set the value using a servlet variable within the out.println statement. I tried escaping the ", that didn't work. I've tried ". No luck there either. It wouldn't be so bad if I didn't finish this one up before my hard drive crashed a while back.
Can anyone provide any other hints.
Thanks and good to be back.
 
Darryl Failla
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not 100% sure I understand your question, but here's a shot:
You are trying to set an HTML input parameter (value) from within the out.println() string. Suppose the string you want to set value to is contained in the String str. Your code would look like: out.println("< input .... value=\"" + str + "\"...>");
Here the value contained in str is concatinated to value=", then "...> is concatinated to that. This completes a correctly formed output string containing str. Hope that answers it.
[ September 16, 2002: Message edited by: Marilyn de Queiroz ]
 
Darryl Failla
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like my html got interpreted instead of printed. The argument of the out.println should be ("...value=\"" + str + "\"..."). Hope this prints better.
 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I simply used double quotes encased within single quotes, which in turn were encased within double quotes. I used the escape codes for replacing apostrophes and quotation marks if they appeared in the text itself.
out.print( "< input tag goes here value='" + variable + "'rest of tag goes here>" ) ;
Have fun getting back in the saddle!
[ September 16, 2002: Message edited by: Marilyn de Queiroz ]
 
Ronald Schindler
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved. I can't believe how long I spent on this. I would have fired me by now. the answer is to use + var +. For some reason this just escaped me. Thanks for the replies.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic