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{
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