Query Modifier : Basics « Servlets « Java






Query Modifier


import javax.servlet.*;
import javax.servlet.http.*;

public class QueryModifier extends HttpServlet {

  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {

    String requestUrl = request.getRequestURL().toString();
    String querystr = request.getQueryString();
    if (querystr != null) {
      querystr = querystr
          + "&inspector-name=Jen&inspector-email=Jenniferq@yahoo.com";
    } else {
      querystr = "inspector-name=Jen&inspector-email=Jenniferq@yahoo.com";
    }

    RequestDispatcher dispatcher = request
        .getRequestDispatcher("/viewPost.jsp?" + querystr);
    dispatcher.forward(request, response);
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {

    doGet(request, response);

  }

}


           
       








Related examples in the same category

1.Using Init Method Servlet
2.Servlet parameter
3.Bean Parser Servlet
4.Post Handler
5.Compression Response Stream servlets
6.Compression Servlet Response Wrapper