Re: Hidden Fields in Java Servlets - help!!!
Dan wrote:
...
I am trying to pass a simple hidden field from one servlet to another
servlet...
Servlets are HTML to the end browser, and like your
other question, anything done in HTML is best debugged
*as* HTML. It is only once the HTML is working that
you should code it as a servlet or similar.
...this is to prevent the second page from being displayed
directly ...
Oh, you wanna' stop me from going whatever the (heck)
path I like on your server? Good luck.. If I am serious
about changing the flow you want to enforce, it is quite
possible, and usually relatively easy*.
..- you have to go through the first page to get to the second
page.
...
Below is my script for my first servlet (the one that you first go to)
Java source code snippets would generally be referred
to as 'code' or 'snippets' about these parts, which brings
me to mentioning that I hope my reply is not also being
x-posted to c.l.js (since that is an inappropriate group for
askling about pure HTML - or servlets!), and the use of the
term 'script' might further confuse matters!
Note also that when posting code, a high preference
is shown for code that constitutes an SSCCE.
<http://www.physci.org/codes/sscce.html>
OTOH - it is not that mysterious why this code
does not work as you might expect.
....
out.println("<html>" +
"<head><title>DirectIt1Servlet.java</title></head>" +
"<body>" +
"<form action=\"/MyWebApp/DirectIt1Servlet2\" method=\"get\"`>" +
"<input type=\"hidden\" name=\"sw\" value=\"y\">" +
"<input type=\"submit\" >" +
"</form>" +
"<p>" + "Below is a button link...
<!-- Button? No! It is just a plain old 'link', the 'submit' button above is
a *button*. -->
... to the correct page that you want.
You cannot get there any other way besides clicking on the link <br /
below:<br />" +
"<br />" +
"<a href=\'http://localhost:9080/MyWebApp/DirectIt1Servlet2'>Link" +
"</a>" +
"</body></html>");
...
* Even easier when the code uses form based 'gets'
that make those 'hidden' parameters very visible
in the resulting URL!
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-setup/200707/1