This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes I'm trying to send XML to a servlet  but the input is always null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "I Watch "I New topic
Author

I'm trying to send XML to a servlet but the input is always null

Gobiraj Vadivelrajan
Greenhorn

Joined: Dec 10, 2001
Posts: 29
I have Java client which sends XML data to a servlet.
I'm writing string data to the output stream but in the servlet the inputstream is always null.
I'm not sure if I'm missing something.
I'm using tomcat 4 and JDK 1.2.2
Thanks for any help.
Java Client Code

Servlet Code
Kevin Black
Greenhorn

Joined: Jan 30, 2003
Posts: 12
http://www-106.ibm.com/developerworks/java/library/j-tunnel/?dwzone=java
Check the article there, it might be helpful.
Kevin
Joe Wilkinson
Greenhorn

Joined: Feb 07, 2002
Posts: 9
Hello,
I was experiencing the same problem. What I found worked to get the string contents of my post is the following code in the servlet :
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
    ServletRequestWrapper srw = new ServletRequestWrapper(request);
    BufferedReader br = srw.getReader();
    StringWriter sw = new StringWriter();
    int bit=0;
    while ((bit=br.read())>=0){
        sw.write(bit);
    }
    sw.flush();
    String contents = sw.toString();
}
Hope this helps you.
Ciao,
Joe
[ April 24, 2003: Message edited by: Joe Wilkinson ]
[ April 24, 2003: Message edited by: Joe Wilkinson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I'm trying to send XML to a servlet but the input is always null
 
Similar Threads
Sending XML files over HTTP
closing streams
Problem with Hebrew encoding
Problems connecting to LDAP from Weblogic Server: BAD_CERTIFICATE error!
Connection in servlets