This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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 ]
Sun Certified Java 2 Programmer
Joined: Oct 16, 2001
It looks like my html got interpreted instead of printed. The argument of the out.println should be ("...value=\"" + str + "\"..."). Hope this prints better.
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 ]
Joined: Jul 11, 2000
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.