Hi.
Try using an InputStreamReader that is a bridge from byte streams to
character streams instead using the getReader() method. Seems like that's
what you want to do, you can then wrap the inputstream reader with any other
type to make accessing it easier.
Hope this works out for you.
Neelesh
>From ServletRequest.java.
=========================
/**
* Retrieves binary data from the body of the request as
* a {@link ServletInputStream}, which
* gives you the ability to read one line at a time.
*
* @return a {@link ServletInputStream}
object containing
* the body of the request
*
* @exception IllegalStateException if the {@link #getReader}
method
* has already been called for
this request
*
* @exception IOException if an input or output
exception occurred
*
*/
public ServletInputStream getInputStream() throws IOException;
============================================================================
=========
/**
* Returns the body of the request as a <code>BufferedReader</code>
* that translates character set encodings.
*
*
* @return a
<code>BufferedReader</code>
* containing the body of the
request
*
* @exception UnsupportedEncodingException if the character set
encoding
* used is not supported and
the
* text cannot be decoded
*
* @exception IllegalStateException if {@link #getInputStream}
method
* has been called on this
request
*
* @exception IOException if an input or output
exception occurred
*
* @see #getInputStream
*
*/
public BufferedReader getReader () throws IOException;
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 14, 1999 5:32 PM
To: [EMAIL PROTECTED]
Subject: Re: Servlet Chaining - returns Null content type
Hi jason,
thanks for the response,
I've ignored the content stuff by just commenting it. Still I have a
problem.
Pls see that after the control enters into the while loop the readline
fetches
only null and hence the whole code doesnt work but hangs and afer some time
it
says 500 internal error (Request timed out).
Pls also note that i havent done any mistake with the HTML file or
configuration
with JWS.
And whenever i open the html file blinky.html Deblink is automatically
activated
which iam able to check by giving System.out.println("Deblink working") at
the
begining. I use JWS and i get the msg in the console of the JWS.
Hope iam clear. Expecting ur reply,
Srinivasan.R
MayFair Center,
Satyam Infoway Ltd,
Secunderabad
R Srinivasan
12/14/99 03:37 AM
To: [EMAIL PROTECTED]
cc:
Subject: Servlet Chaining - returns Null content type (Document link not
converted)
Hi all,
Iam just trying out some examples in jason hunterz.
As a typical example, iam running the following program which will remove
all
blinks from any html page displayed.
Iam using jws 2.0 running in win nt
The program is this
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Deblink extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException{
System.out.println("Deblink Started:);
String contentType = req.getContentType();
System.out.println("Content type is " + contentType); // juss to
test
things out
if(contentType == null) return;
res.setContentType(contentType);
PrintWriter out = res.getWriter();
BufferedReader in = req.getReader();
String line = null;
while((line = in.readLine()) != null){
System.out.println("entered loop");
line=replace(line,"<BLINK>","");
line=replace(line,"</BLINK>","");
out.println(line);
}
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException{
doGet(req,res);
}
private String replace(String line, String oldString, String
newString){
int index = 0;
while((index = line.indexOf(oldString,index))>=0){
//Replace old string with the new string (inefficiently)
line = line.substring(0,index)+
newString + line.substring(index+oldString.length());
index = index + newString.length();
}
return line;
}
}
which naturally should remove all blinks in all html pages. I've made
necessary
changes into jws config to make Deblink servlet to run whenever an html is
requested.
But all i get is null content type and the whole document is null, which i
found
out by just adding System.out.println("Content type is " + contentType);
Just tried my best, but cudnt come with an answer. Can somebody help?
Srinivasan.R
Satyam Infoway Ltd.,
May Fair Center,
Secunderabad
___________________________________________________________________________
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
___________________________________________________________________________
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