运行Servlet无任何显示无错误信息

qq_39208530 学生  2017-11-18 10:29:23
package zzu;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

import javax.servlet.GenericServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ServletInfo extends GenericServlet {
private Map initPara=new LinkedHashMap();
private String servletName=null;
@Override
public void service(ServletRequest arg0, ServletResponse arg1)
throws ServletException, IOException {
// TODO Auto-generated method stub

}

/**
* Constructor of the object.
*/
public ServletInfo() {
super();
}

/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}

/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void init(ServletConfig config) throws ServletException {
super.init(config);

Enumeration enumeration=getInitParameterNames();
while (enumeration.hasMoreElements()) {
String name = (String) enumeration.nextElement();
String value=(String)getInitParameter(name);
this.initPara.put(name, value);
}
this.servletName=getServletName();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"><TITLE>获取servlet自身信息</TITLE></HEAD>");
out.println(" <BODY>");
out.print("servlet自身的信息:<br/>");
out.print("<table border=1><tr><th>参数名</th><th>参数值</th></tr>");
Set set=initPara.keySet();
Iterator iterator=set.iterator();
while(iterator.hasNext()){
String name=(String)iterator.next();
String value=(String)initPara.get(name);
out.println("<tr><td>"+name+"</td><td>"+value+"</td></tr>");
}
out.println("</table");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}

/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

doGet(request, response);
}

/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/


}
...全文
99 回复 点赞 打赏 收藏 举报
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
其他
加入

1.0w+

社区成员

Web 开发 其他
申请成为版主
帖子事件
创建了帖子
2017-11-18 10:29
社区公告
暂无公告