Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 29th, 2004, 10:20 AM
Registered User
 
Join Date: Apr 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to read HTTP Body using servelts

Hi,
I my application there is a scenario, where the client will send an HTTP POST request with '900 success' in HTTP BODY. How to read this in a servlet.
thanks in advance
 
Old June 27th, 2006, 10:00 PM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i've done in asp.net :

<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>

<script runat="server">
Sub Page_Load()
'-- Stream Reader --
Dim MyStream As Stream
Dim strTemp as String = ""

MyStream = context.Request.InputStream
Dim rdr As StreamReader = New StreamReader(MyStream)
Dim linesread As integer = 1
Dim inLine As String = rdr.ReadLine()
while not inLine is Nothing
linesread += 1
strTemp &= inLine
inLine = rdr.ReadLine()
end while
strTemp = Trim(strTemp)
dim dbg AS integer = 1
if dbg = 1 then
Dim FILENAME as String = Server.MapPath("Notification.txt")
Dim objStreamWriter as StreamWriter
objStreamWriter = File.AppendText(FILENAME)
objStreamWriter.WriteLine("-------------------------")
objStreamWriter.WriteLine("Write at: " & DateTime.Now.ToString())
objStreamWriter.WriteLine("ALL Stream : -" & strTemp & "-")
objStreamWriter.Close()
end if

if strTemp = "900 Success" then
response.write ("Success Response")
Else
response.write ("Not Success Response")
End if
End Sub
</script>

 
Old July 1st, 2006, 08:02 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

(HttpServletRequest)request.getInputStream()

Jon Emerson
http://www.jonemerson.net/





Similar Threads
Thread Thread Starter Forum Replies Last Post
typing abc.com opens http://abc.com and not http:/ nrlahoti ASP.NET 2.0 Professional 1 February 6th, 2008 01:43 PM
can any body tell me about this yammirza J2EE 1 January 3rd, 2005 04:16 AM
Response.Write output is of <body></body> yoord BOOK: Beginning ASP.NET 1.0 0 October 13th, 2004 07:06 AM
Read File Using HTTP fredaffini General .NET 0 August 3rd, 2004 04:46 PM
HTTP Status 405 - HTTP method GET .... nsakic Servlets 1 January 25th, 2004 04:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.