Oleg Kirillov

Greenhorn
+ Follow
since Jun 07, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Oleg Kirillov

//pd1.jsp
<form action="pd2.jsp" method="post">
<input type="hidden" name="nic" value="hello">
<input type="text" name="sex" value="male">
<input type="submit">
</form>

After user click submit button, this is the process jsp:
//pd2.jsp
<%
System.out.println(request.getHeader("Referer"));
System.out.println(request.getParameter("nic"));
System.out.println(request.getParameter("sex"));
%>

The log message is:
/pd.jsp?nic=hello&sex=male
null
null


I guess problem is here:
<form action="pd2.jsp" method="post">
You set method to "post", not "POST". The size, i.e. case does matter! If you try to look at http traffic you'll notice that really your browser used a GET method on this form as it parsed method attribute incorrectly.

In my case the situation is much worse.
I use Oracle Container for Java (OC4J) and when I use POST method to send form parameters I cannot retrieve any parameters. All of them are "null" no matter what browser I use. Also - I sniffed my HTTP traffic and I see that POST method works and it uses a correct enctype (enctype="multipart/form-data") to send parameters. I've tried Tomcat 4.12 - it shows the same result. The code is:
<%@ page contentType="text/html"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>untitled</title>
</head>
<body>
<form action="testenc2.jsp" enctype="multipart/form-data" method="POST">
TXT<input type="TEXT" name="txt" size="50" value="text1"/><br>
MLTXT<textarea name="mltxt" rows="10" cols="50">TA test</textarea><br>
<input type="HIDDEN" name="tst" value="test"/>
<input type="SUBMIT"/>
</form>
</body>
</html>

The POST operation sends the following data:
---------------------
POST http://192.168.32.122:8989/DemokitsII-Viewer-context-root/testenc2.jsp HTTP/1.1
Host: 192.168.32.122:8989
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
Accept-Language: ru,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Referer: http://192.168.32.122:8989/DemokitsII-Viewer-context-root/testenc1.jsp
Cookie: JSESSIONID=c0a8207a231dc0874bc6e16f4a7cad0cc8f6131e8c95
Content-Type: multipart/form-data; boundary=---------------------------6483275954041
Content-Length: 490

-----------------------------6483275954041
Content-Disposition: form-data; name="txt"

text1
-----------------------------6483275954041
Content-Disposition: form-data; name="mltxt"

TA test
-----------------------------6483275954041
Content-Disposition: form-data; name="tst"

test
-----------------------------6483275954041

---------------------

ALL request attributes are null. Looks like I missed something...
[ June 07, 2004: Message edited by: Oleg Kirillov ]
13 years ago
JSP