Results 1 to 6 of 6

Thread: URL rewriting in JSP

  1. #1
    Join Date
    Nov 2009
    Posts
    652

    URL rewriting in JSP

    Hello, I am learning java programming language. I am recently started studying JSP and quiet confused about the URL rewriting in JSP. I am not able to understand this concept. So, if anyone is having knowledge about it, then please provide me help regarding it. If anyone is having program regarding it, then please provide me that also.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: URL rewriting in JSP

    If you want to make use of the URL rewriting in JSP then you need to use the code below for your jsp code. It will rewrite your jsp page and provide the solution for which you want.
    Code:
    <%@ page session ="true" %>
    <%  
        String str = request.getParameter("str");
    	String password = request.getParameter("pwd");
    	if(str.equals("Techarena") && password.equals("12345"))
    	{
    		session.setAttribute("userstr",str);
    		String word = response.encode
    URL("NextPageAfterFirst.jsp?str=+str+&password=+password");
    		%>
    		<font size = 5><p>Please click here to go forward : </p></font>
    		<font size = 7><a href ='<%= word %>'>WelcomeEncodeURL.jsp</a></font>
    	<%}
    	else
    	{
    		String word = response.encode
    URL("changeURL.jsp?str=+str+&password=+password");%>
    		<font size = 5><p>You have entered a wrong 
    value  : Click here to go back : </p></font>
    		<font size = 5><a href ='<%= word %>'>changeURL.jsp</a></font>
    	<% }
    	%>

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: URL rewriting in JSP

    Hello, URL Rewriting is mostly used for the purpose where you don't want to use the cookies. That means it will take care of your overall session when you are not having cookies. So, it will do one thing, when browser send any type of request to the server side then it will be used as a new request each time. This happen as http protocol is a stateless protocol. For providing session tracking it is necessary to create a session object. So, you have the ability in jsp to make use of the URLRewriting if you are not having the cookie facility at the client side.

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: URL rewriting in JSP

    If you want to write URL rewriting, then it is necessary to create a link below:
    Code:
    <a href="save/catalog;$jsessionid$DA32242SSGE2"> 
    <%
     response.encodeURL ("save/catalog");
    %>
    out.println("<a href=\""); 
    out.println(response.encodeURL ("/save/catalog")); 
    out.println("\">catalog</a>");
    response.sendRedirect (response.encodeRedirectURL ("http://myhost/store/catalog"));

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: URL rewriting in JSP

    Hello, I am also new in java programming language. And I am having really small knowledge about the jsp. But, I have some idea about the URL Rewriting. It is a process from which you will able to get the details about the user browser between page use. It is quiet similar to the cookie and it will work in place of the cookie. It will store your information into the url which can be used as an another parameter.

  6. #6
    Join Date
    Apr 2008
    Posts
    2,005

    Re: URL rewriting in JSP

    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);
      }
    }

Similar Threads

  1. Changing url while rewriting the paramerts in url
    By Farzana in forum Software Development
    Replies: 5
    Last Post: 28-06-2011, 04:46 AM
  2. Preparing for PHP url rewriting
    By AZUL in forum Software Development
    Replies: 3
    Last Post: 20-10-2009, 04:54 PM
  3. IIS Support URL Rewriting?
    By Chrisch in forum Software Development
    Replies: 3
    Last Post: 10-08-2009, 12:40 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,157,839.75329 seconds with 16 queries