Hello, I have got the following code for testing of the URL rewriting in java:
Code:
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class testing extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException
{
response.setContentType("text/html");
java.io.PrintWriter output = response.getWriter();
String str = request.getContextPath();
String str2 = response.encodeURL(str + "/testing.jsp");
output.println("<html>");
output.println("<head>");
output.println("<title>URL Rewriter</title>");
output.println("</head>");
output.println("<body>");
output.println("<h1>This page will use URL rewriting if necessary</h2>");
output.println("Go to the testing.jsp page <a href=\"" + str2
+ "\">here</a>.");
output.println("</body>");
output.println("</html>");
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException
{
doGet(request, response);
}
}
Bookmarks