Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
Unable to pass string in hidden field
Farakh khan
Ranch Hand
Posts: 851
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello,
//sendNewsletterView public String sendNewsletterView(String message){ EmailsDAO ed = new EmailsDAO(); String view= "<form action=\"/servlet/SendPromo\" method=\"post\" accept-charset=\"UTF-8\">"+ "<center><table border=0 >"+ "<tr>"+ "<td class=pageHeading >Send Email Template</td>"+ "</tr>"+ "<tr>"+ "<td class=loginFont1 >From </td>"+ "<td > "+ "<input name='from' class='zinput1' type=\"text\"></td> "+ "</tr>"+ "<tr>"+ "<td class=loginFont1>Subject </td>"+ "<td > "+ "<input name='subject' class='zinput1' type=\"text\"></td> "+ "</tr>"+ "<tr>"+ "<td></td><td ><select name='catId' class=zinput1>"+ "<option value=''>--Select Category--</option>"+ "<option value=\"00\">Test</option>"+ ed.displayCategories("3","1")+ "</select></td>"+ "</tr>"+ "<tr><td ><br><br>"+ "<input type=\"hidden\" name=\"message\" value=\""+message+"\">"+ "<input type=\"button\" class=\"zsubmit\" value=\"Cancel\" "+ " onClick='location.href=\"/servlet/AdminManager?option=1\"'>"+ "<input type='submit' class='zsubmit' name='sendTemplate' value='Send'>"+ "</td></tr></table></form></center>"+ "<br><br><center>"+ "<table border=0 >"+ "<tr><td class=normalFont>"+ "<img ><br><br>"+ "<table border=0 ><tr><td>"+ message+"</td></tr></table><br><br>"+ "</td></tr>"+ "</table></center>"; return view; }//
This line
"<input type=\"hidden\" name=\"message\" value=\""+message+"\">"+
is actual problem. This is hidden type but printing in HTML page. Why?
Thanks in anticipation
Best regards
Zandis Murāns
Ranch Hand
Posts: 174
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Are you sure that this is not what causes that message appear in HTML?
"<table border=0 ><tr><td>"+ message+"</td></tr></table><br><br>"+
Farakh khan
Ranch Hand
Posts: 851
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Yes I am sure as I am printing and sending in form as well. The value is too much characters and pictures that cause the break of hidden input.
Zandis Murāns
Ranch Hand
Posts: 174
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I see your problem now. You must escape your
string
printed in value attribute.
Farakh khan
Ranch Hand
Posts: 851
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Zandis Murāns wrote:
I see your problem now. You must escape your string printed in value attribute.
You are right but how can I pass it to form? Is there any other way to deal it?
best regards
Zandis Murāns
Ranch Hand
Posts: 174
I like...
posted 12 years ago
1
Number of slices to send:
Optional 'thank-you' note:
Send
You can use, for example apache commons-lang api to escape HTML. Add apache-lang aip library to your project and then use it like:
org.apache.commons.lang.StringEscapeUtils.escapeHtml(message)
Farakh khan
Ranch Hand
Posts: 851
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Dear Zandis Murāns I am grateful to you from the bottom of my heart. The problem fixed
Best regards
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
servlets/jsp
raw HTML in Mozilla
Forms in servlet
have problem with multiple forms on a jsp
Getting "not a multipart request" even though the image is being saved.
More...