Beginner Question: ---- response.encodeURL

Posted on 2006-05-24
Last Modified: 2010-04-01
1. I know that encodeURL support redirect, but how about request dispatcher's forward() ??

2. Can I OR do I need to encode the url for my html form action?
   <form name="myform" action="???">
Question by:InNoCenT_Ch1ld
    LVL 23

    Assisted Solution

    1) RequestDispatcher.forward(), forwards a request to another resource on the same server. The
    resource may be a Servlet, JSP page or a simple HTML page.

    2) not neccessarily. but you can try some thing like this check out.
    LVL 3

    Author Comment

    Tks for responding ;-)

    Question 1. I mean we can do this: response.encodeRedirectURL... so is there a way to encode the url that we are going to "forward" to.... (I know about the RequestDispatcher.forward()).
    LVL 4

    Accepted Solution

    Encoding a URL is meant for maintaining session state.  It is so the client can tell the server which session it is part of.
    Basically the encodeURL method encodes a URL by adding the sessionid onto it if necessary - ie if the client has cookies turned off, and does not have the sessionid in a cookie.

    You only need to encode URLs that are going to be sent to the client.  eg all hyperlinks on a webpage, and all urls that you redirect to.
    You don't need to encode a URL you are forwarding/including via the request dispatcher.  That transfer is done on server only, and never gets to the client.

    There are slightly different rules for encoding a url for a redirect as opposed to encoding a url for printing on a page, hence the two seperate methods.

    LVL 3

    Author Comment

    Tks evnafets, it clears up my mind now ;-)

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    constuctor calling other constructor 2 73
    Fisheye tool 2 96
    immutable object concept 5 96
    Handle form fields in spring mvc controller 1 50
    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now