J
James
Hell Gurus,
I have a stupid question here need your mighty hands.
I wrote a very simple Servlet to test the POST data function:
==
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class Test extends javax.servlet.http.HttpServlet {
public void service(HttpServletRequest req, HttpServletResponse resp) {
try {
BufferedInputStream is = new
BufferedInputStream(req.getInputStream());
int available = is.available();
byte[] buf= new byte[8192];
int count = is.read(buf,0, available );
ServletOutputStream out = resp.getOutputStream();
out.println( available + " " + count);
} catch (Exception e ) {}
}
}
==
And I use the following HTML page to send the request to this servlet:
==
<html>
<body>
<form ACTION="http://localhost:8080/Test" METHOD="POST">
<TEXTAREA ROWS=5 COLS=72 NAME=Comments></TEXTAREA>
<input type="Submit">
</form>
</body>
</html>
==
The problem is, the servlet always says that there is no data available
in the inputstream. I have tried everything I know but it stays the
same. I also tried to use enctype="multipart/form-data" on the browser
side...
Can anyone please point me to a correct direction? I have spent hours
over internet and news groups trying to find an answer...
Note: the test was done on Tomcat 5.0.28 + JDK 1.4.2
Thanks a lot in advance!!
I have a stupid question here need your mighty hands.
I wrote a very simple Servlet to test the POST data function:
==
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class Test extends javax.servlet.http.HttpServlet {
public void service(HttpServletRequest req, HttpServletResponse resp) {
try {
BufferedInputStream is = new
BufferedInputStream(req.getInputStream());
int available = is.available();
byte[] buf= new byte[8192];
int count = is.read(buf,0, available );
ServletOutputStream out = resp.getOutputStream();
out.println( available + " " + count);
} catch (Exception e ) {}
}
}
==
And I use the following HTML page to send the request to this servlet:
==
<html>
<body>
<form ACTION="http://localhost:8080/Test" METHOD="POST">
<TEXTAREA ROWS=5 COLS=72 NAME=Comments></TEXTAREA>
<input type="Submit">
</form>
</body>
</html>
==
The problem is, the servlet always says that there is no data available
in the inputstream. I have tried everything I know but it stays the
same. I also tried to use enctype="multipart/form-data" on the browser
side...
Can anyone please point me to a correct direction? I have spent hours
over internet and news groups trying to find an answer...
Note: the test was done on Tomcat 5.0.28 + JDK 1.4.2
Thanks a lot in advance!!