tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Graham" <da...@sound.ee.umist.ac.uk>
Subject Re: URL Redirect
Date Thu, 10 Apr 2003 07:39:21 GMT
A simple example ..
----------------8<---------------
<%
        response.reset();
        response.resetBuffer();

        String redirect_to = "http://yoursite.com";

        redirect_to = response.encodeRedirectURL( redirect_to );

        response.sendRedirect( redirect_to );
%>
----------------8<---------------

Is about all you need in a .jsp file.

Get a good IDE (e.g. NetBeans -- but see the recent IDE thread), you can
write
and compile .jsp's directly in the IDE .. and this will give you a good
insight into
what happens at run time... and save you debugging elementary stuff on the
app server.

(Basic Overview) - apologies for any inaccuracies ..
====================================

a JSP get's compiled into a Java class, with the code between <% %> being
inserted into the main "service" function of the servlet .. (it differs
depending on compiler
I think, but in Tomcat this method is called "_jspService" ..

Here's what Tomcat puts at the begining of the call ..

    public void _jspService(HttpServletRequest request, HttpServletResponse
response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    javax.servlet.jsp.PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html;charset=ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response,
                        null, true, 8192, true);
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;


... after this comes your code inside the "<% %>" tags...

.. so you can see where the "response" and "request" objects come from.

This allows you do to tihngs like get request parameters in your servlet ..

    http://server/app/index.jsp?string=hello

you can do :

    String hello_str = request.getParameter("string");

to give hello_str the value of "hello"...

HTH.

There's plenty of this stuff on the web and several OReilliy/Wrox books.

DG

----- Original Message -----
From: "krip pane" <jkrp123@yahoo.com>
To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
Sent: Wednesday, April 09, 2003 8:44 PM
Subject: RE: URL Redirect


> Hi Yoa,
>
> I'm a newbie...Can you please expand on the solution
>
> Thanks
>
>
> --- "Shapira, Yoav" <Yoav.Shapira@mpi.com> wrote:
> >
> > Howdy,
> > Or a simple HTML file sitting at the root with a
> > <META REFRESH...> tag
> > pointing to your index.jsp URL.
> >
> > Yoav Shapira
> > Millennium ChemInformatics
> >
> >
> > >-----Original Message-----
> > >From: Daniel Graham
> > [mailto:danny@sound.ee.umist.ac.uk]
> > >Sent: Wednesday, April 09, 2003 3:12 PM
> > >To: Tomcat Users List
> > >Subject: Re: URL Redirect
> > >
> > >try
> > >
> > >response.sendRedirect( ".... your url " );
> > >
> > >DG
> > >----- Original Message -----
> > >From: "krip pane" <jkrp123@yahoo.com>
> > >To: "tomcat" <tomcat-user@jakarta.apache.org>
> > >Sent: Wednesday, April 09, 2003 8:09 PM
> > >Subject: URL Redirect
> > >
> > >
> > >> Hi,
> > >>
> > >> Can someone please help in redirecting url's with
> > >> tomcat as standalone server.
> > >>
> > >> I would like to redirect all requests for
> > >> http://www.abc.com/xyz/abc/index.jsp
> > >>
> > >> so that when a user types
> > >> http://www.abc.com
> > >>
> > >> they'll be redirected to the first URL.
> > >>
> > >> TIA
> > >>
> > >>
> > __________________________________________________
> > >> Do you Yahoo!?
> > >> Yahoo! Platinum - Watch CBS' NCAA March Madness,
> > live on your
> > desktop!
> > >> http://platinum.yahoo.com
> > >>
> > >>
> >
> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail:
> > tomcat-user-unsubscribe@jakarta.apache.org
> > >> For additional commands, e-mail:
> > tomcat-user-help@jakarta.apache.org
> > >
> >
> >---------------------------------------------------------------------
> > >To unsubscribe, e-mail:
> > tomcat-user-unsubscribe@jakarta.apache.org
> > >For additional commands, e-mail:
> > tomcat-user-help@jakarta.apache.org
> >
> >
> >
> >
> > This e-mail, including any attachments, is a
> > confidential business communication, and may contain
> > information that is confidential, proprietary and/or
> > privileged.  This e-mail is intended only for the
> > individual(s) to whom it is addressed, and may not
> > be saved, copied, printed, disclosed or used by
> > anyone else.  If you are not the(an) intended
> > recipient, please immediately delete this e-mail
> > from your computer system and notify the sender.
> > Thank you.
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > tomcat-user-help@jakarta.apache.org
> >
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
> http://platinum.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message