wood burning stoves*
The moose likes Servlets and the fly likes a simple filter with a simple question. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "a simple filter with a simple question." Watch "a simple filter with a simple question." New topic
Author

a simple filter with a simple question.

cer
Greenhorn

Joined: Sep 28, 2002
Posts: 8
hi,all
ijust want to write a ample to realize the function to open a new html page.the similar javascripts code is
<script language="javascript">
window.open("a.jsp","","")
</script>
now what puzzle me is that when i realize with java Servlet,it didn't work.
the code is:
[code]package org.w3c.jigsaw.filters;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import org.w3c.tools.resources.Attribute;
import org.w3c.tools.resources.AttributeHolder;
import org.w3c.tools.resources.AttributeRegistry;
import org.w3c.tools.resources.IntegerAttribute;
import org.w3c.tools.resources.ReplyInterface;
import org.w3c.tools.resources.RequestInterface;
import org.w3c.tools.resources.ResourceFilter;
import org.w3c.jigsaw.http.Request;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2000</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2000</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class Adv extends ResourceFilter{
private static final String CONTENT_TYPE = "text/html; charset=GBK";
//Initialize global variables
static {
Attribute a = null ;
Class cls = null ;
try {
cls = Class.forName("org.w3c.jigsaw.filters.Adv") ;
} catch (Exception ex) {
ex.printStackTrace() ;
System.exit(1) ;
}

}
public void init() throws ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Adv</title></head>");
out.println("<body bgcolor=yellow>");
out.println("<font color=red size=10");
out.println("This is just an example for adv who route on me.<br>");
out.print("</font>");
out.println("<p>The servlet has received a GET. This is the reply.</p>");
out.println("</body></html>");
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Adv</title></head>");
out.println("<body bgcolor=yellow>");
out.println("<font color=red size=10");
out.println("This is just an example for adv who route on me<br>");
out.println("</font>");
out.println("<p>The servlet has received a POST. This is the reply.</p>");
out.println("</body></html>");
}
//Clean up resources
public void destroy() {
}
}
[code]
who can help me out
with many thanks


Nice to meet you here.<br />I will learn from you.
 
jQuery in Action, 2nd edition
 
subject: a simple filter with a simple question.