This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a simple filter with a simple question.

 
cer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic