package com.gordon.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.annotation.WebInitParam; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class TestAjax */ @WebServlet(name = "testservlet", urlPatterns = { "/testservlet1", "/testservlet2" }, initParams = { @WebInitParam(name = "name", value = "value1"), @WebInitParam(name="name1", value="value2")}) public class TestAjax extends HttpServlet { private String name; private String name1; private static final long serialVersionUID = 1L; public TestAjax() { super(); } public void init(ServletConfig config) throws ServletException { // TODO Auto-generated method stub this.name = config.getInitParameter("name"); this.name1 = config.getInitParameter("name1"); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter pw = response.getWriter(); pw.append("Served at: ").append(request.getContextPath()); pw.append("--------------------"); pw.append(this.name); pw.append("--------------------"); pw.append(this.name1); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }