Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

Beginner Question: ---- response.encodeURL

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="???">
0
InNoCenT_Ch1ld
Asked:
InNoCenT_Ch1ld
  • 2
2 Solutions
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
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.

http://list.jahia.org/dev_list/msg00555.html
0
 
InNoCenT_Ch1ldAuthor Commented:
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()).
0
 
evnafetsCommented:
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.

Cheers,
evnafets
0
 
InNoCenT_Ch1ldAuthor Commented:
Tks evnafets, it clears up my mind now ;-)
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now