Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Reverse2Servlet

 
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.
 
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.
 
village idiot
Posts: 1207
  • 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.
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic