I have a question about servlet mapping using response.sendRedirect() for local 
language navigation:

1) What impact does using servlet mapping and response.sendRedirect() have on IIS and 
JRun connections?
Is there any risk of this increasing the use of available HTTP connections and 
crashing either JRun or IIS
if load is high?

This seems to perform fine in insolated stress tests but production usage may
vary based on server load and request parameters(processing and encoding each 
name/value pair
for URLs with long query strings could add overhead).


I have found searching the archives:
1) response.sendRedirect() requires a round trip to the browser
2) response.sendRedirect() is the only way to force the URL to change in the user's 
browser(as opposed to using forward())
3) response.sendRedirect() does not forward request parameters so they must be parsed, 
URLEncoded and added to sendRedirect() query string
4) forward() automatically forwards request object so no need to parse and encode 
request parameters
(It sounds like we are forced to comply with #2 for usability of site - site producers 
request user be able to bookmark pages )

The  RedirectController servlet is a URL mapped servlet used to redirect to local 
language pages across a large site.
URL mapping provided a convenient way to to do redirects across the site whereever 
absolute URLs had to be used in global pages.
Maintainance is easier since all language redirects are controlled by a single
servlet in one place (rather than using JSP level code in every page across the site)
as we use this in links and redirects across the site I worry about performance:

/redirect/index.jsp?url=http//www.ibm.com&language=en
/en/index.jsp?url=http%3A%2F%2Fwww.ibm.com&language=en

/redirect/index.jsp?http://www.hp.com&language=de
/de/index.jsp?url=httphttp%3A%2F%2Fwww.hp.com&language=de



RedirectController.java:
public class RedirectController extends HttpServlet {

private static final String ENU = "en";
...
private boolean isDebug = false;

public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, 
ServletException {

     ServletContext sc = this.getServletContext();
     RequestDispatcher rd = sc.getRequestDispatcher(toURL);
     HttpSession session = req.getSession();
     UserBean user = session.getAttribute("user");
     String contextPath = (String)req.getPathInfo();
     // returns encoded request parameters
     Vector parameters = this.getRequestParameters(req, res);
     String queryString = this.toQueryString(parameters);
     // user.getLanguage() returns 2 letter language code
     String toURL = this.toURL(contextPath, queryString, user);
     res.sendRedirect(toURL);

  }
}

web.xml:
 <servlet>
  <servlet-name>RedirectController</servlet-name>
  <servlet-class>com.servlets.RedirectController</servlet-class>
 </servlet>

IIS log file:

2002-02-08  GET /redirect/index.jsp?url=http://www.hp.com&language=de 200 455 1472 15 
HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0b;+Windows+NT+5.0)
2002-02-08  GET /de/index.jsp?url=httphttp%3A%2F%2Fwww.hp.com&language=de 200 335 1494 
16 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0b;+Windows+NT+5.0)

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to