Discussions

Web tier: servlets, JSP, Web frameworks: Http Redirects

  1. Http Redirects (2 messages)

    I am new at sw web development so if this is not the forum to ask this, then please redirect me to the right location... This is not a pun to my redirect topic. I have reviewed the Http1.1 spec, read several articles and other documentation with regards to rerects, but I seem to still not understand the syntax for doing a redirect. Java/J2EE - what would I code in the servelt? Specifically, I have a item and URL stored in my database on my server. I want to redirect through asnother server prior to the final URL. My server is www.myserver.com Stored URL is www.storedurl.com Other server is www.otherserverURL.com what is the sytax: redirect 307 Http://www.otherserverURL.com/www.storedURL.com/

    Threaded Messages (2)

  2. Re: Http Redirects[ Go to top ]

    Probably looking at the wrong documentation then.. ;-) If you want to do redirects in J2EE, have a look at the J2EE servlet API docs, not the generic http protocol spec. To get you started, what you probably want to do is invoke the sendRedirect() method on an HttpServletResponse instance. Conveniently, one happens to be passed into the service methods of the servlet... (Assuming you are using HttpServlet, which you should). Regards, Jeroen
  3. Re: Http Redirects[ Go to top ]

    1) Use response.sendRedirect(String URL). Example response.sendRedirect("http://yahoo.com");. then client get code=302 with the URL=http://yahoo.com in the response body and Browser redirect window to this URL. 2) User Dispatchers for redirecting inside your j2ee server. RequestDispatcher dispatcher = request.getRequestDispatcher("/c/do.jsp"); dispatcher.forward(request, response); then server redirect request transparently to the "/c/do.jsp".