aspose file tools*
The moose likes Cattle Drive and the fly likes Reverse2Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Reverse2Servlet" Watch "Reverse2Servlet" New topic
Author

Reverse2Servlet

Ronald Schindler
Ranch Hand

Joined: Jul 11, 2000
Posts: 50
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

Joined: Oct 16, 2001
Posts: 129
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
Sun Certified Java 2 Programmer
Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 129
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

Joined: Mar 15, 2001
Posts: 1199
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

Joined: Jul 11, 2000
Posts: 50
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reverse2Servlet