Hello everybody!
Surfing in Internet I have seen that some html forms use input hidden
fields without name, like this:
<input type=hidden value="">
It is very strange....what are they useful for??? :-(
Anyway I would like to get in my Java servlets such type of parameters but I
don't know how to do because the getParameterNames() method of
HttpServletRequest object needs that the input field has a name to get its
value!
Then I would ike to simulate an html form and I would like to be able to
send parameter without name (see above) to another servlet (called
"ServletB"): how can I do?
To encode the parameters to send and their values I use this Java code:
..
String
ParamHtml=ParamName1+"="+URLEncoder.encode(ValueParam1)+"&"+ParamName2+URLEn
coder.encode(ValueParam2)+...;
HttpURLConnection Con = (HttpURLConnection)url.openConnection();
Con.setRequestMethod("POST");
Con.setDoOutput(true);
Con.setUseCaches(false);
Con.setRequestProperty("Content-Length",""+ParamHtml.length());
Con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
ByteArrayOutputStream byteStream=new ByteArrayOutputStream(512);
PrintWriter out=new PrintWriter(byteStream,true);
out.print(ParamHtml);
out.flush();
OutputStream Os=Con.getOutputStream();
byteStream.writeTo(Os);
..
In this case if ParamName1 is a parameter without name and without value
(<input type=hidden value="">)ParamNameHtml should have the following value:
=&ParamName2+URLEncoder.encode(ValueParam2)+...;
Is it so? I tried to codify it in this way but when ServletB receives the
parameters it isn't able to read them because the syntax seems to be
wrong....:-(
Can someone help me?
Thanks in advance!
Luca
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html