How to redirect the application to https for particular urls

Discussion in 'Java' started by itmohan2002@gmail.com, Nov 15, 2008.

  1. Guest

    Hi All,

    In my web application, i would like to redirect to https to some urls
    (ex:- registration, posting)
    Iam using struts framework, Ibatis and sever Tomcat 5.0.
    How can i redirect to https for particular urls and the next coming
    pages should come back to http.
    ex:-
    --------------------------------------------------------------------------------
    http://www.myapp.com
    https://www.myapp.com/register.do
    http://www.myapp.com/thankyou.do

    --------------------------------------------------------------------------------

    Struts-config.xml

    --------------------------------------------------------------------------------
    <!-- ======== REGISTRATION ===== -->
    <action attribute="registerForm" name="registerForm" path="/
    registration" validate="false"
    type="com.app.registration.RegisterAction">
    <forward name="registration" path="/registration/registration.jsp"/>
    <forward name="alreadyLoggedIn" path="/edit-profile.do"/>
    </action>
    <!-- ======== CONFIRM REGISTRATION ===== -->
    <action attribute="registerForm" name="registerForm" path="/thankyou-
    registration" validate="false"
    type="com.app.registration.RegisterAction">
    <forward name="registerFailure" path="/registration/registration.jsp"/
    >

    <forward name="successRegistration" path="/registration/thankyou-new-
    registration.jsp"/>
    </action>
    --------------------------------------------------------------------------------
    Where should i configure the settings.
    Please help me.
    Thanks in advance.
    , Nov 15, 2008
    #1
    1. Advertising

  2. wrote:
    > Hi All,
    >
    > In my web application, i would like to redirect to https to some urls
    > (ex:- registration, posting)
    > Iam using struts framework, Ibatis and sever Tomcat 5.0.
    > How can i redirect to https for particular urls and the next coming
    > pages should come back to http.
    > ex:-
    > --------------------------------------------------------------------------------
    > http://www.myapp.com
    > https://www.myapp.com/register.do
    > http://www.myapp.com/thankyou.do
    >
    > --------------------------------------------------------------------------------
    >
    > Struts-config.xml
    >
    > --------------------------------------------------------------------------------
    > <!-- ======== REGISTRATION ===== -->
    > <action attribute="registerForm" name="registerForm" path="/
    > registration" validate="false"
    > type="com.app.registration.RegisterAction">
    > <forward name="registration" path="/registration/registration.jsp"/>
    > <forward name="alreadyLoggedIn" path="/edit-profile.do"/>
    > </action>
    > <!-- ======== CONFIRM REGISTRATION ===== -->
    > <action attribute="registerForm" name="registerForm" path="/thankyou-
    > registration" validate="false"
    > type="com.app.registration.RegisterAction">
    > <forward name="registerFailure" path="/registration/registration.jsp"/
    > <forward name="successRegistration" path="/registration/thankyou-new-
    > registration.jsp"/>
    > </action>
    > --------------------------------------------------------------------------------
    > Where should i configure the settings.
    > Please help me.
    > Thanks in advance.


    I don't know struts very well, but isn't this usually done in Apache
    running in front of Tomcat?

    Jeff
    Jeffrey H. Coffield, Nov 15, 2008
    #2
    1. Advertising

  3. Mark Space Guest

    Jeffrey H. Coffield wrote:

    >
    > I don't know struts very well, but isn't this usually done in Apache
    > running in front of Tomcat?


    From what I understand about Java EE, it duplicates a lot of things
    Apache does. This allows you to run a Java EE under any web server,
    because your web app is now described independently of the platform
    (Apache, IIS, etc.) it is running on.

    In other words, the OP is likely doing the right thing. Sorry that I
    don't know enough about struts to puzzle out how to redirect. It should
    be easy, just a matter of getting the syntax right.
    Mark Space, Nov 15, 2008
    #3
  4. Arne Vajhøj Guest

    Mark Space wrote:
    > Jeffrey H. Coffield wrote:
    >> I don't know struts very well, but isn't this usually done in Apache
    >> running in front of Tomcat?

    >
    > From what I understand about Java EE, it duplicates a lot of things
    > Apache does. This allows you to run a Java EE under any web server,
    > because your web app is now described independently of the platform
    > (Apache, IIS, etc.) it is running on.


    Java EE app servers are not running "under" any web server. They run
    standalone. The browser can connect directly to them. Or the browser
    can go to a web server that forward requests either via AJP or HTTP.

    Arne
    Arne Vajhøj, Nov 15, 2008
    #4
  5. Arne Vajhøj Guest

    wrote:
    > In my web application, i would like to redirect to https to some urls
    > (ex:- registration, posting)
    > Iam using struts framework, Ibatis and sever Tomcat 5.0.
    > How can i redirect to https for particular urls and the next coming
    > pages should come back to http.


    You can require that certain URL's can only be accessed via HTTPS
    using <user-data-constraint><transport-guarantee> in web.xml.

    You could write a servlet filter that did a redirect for
    certain URL's.

    That is the two options that I can think of.

    Arne
    Arne Vajhøj, Nov 16, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kaidi
    Replies:
    5
    Views:
    454
    Andrew Thompson
    Jan 4, 2004
  2. Nathan Sokalski

    Converting Relative URLs into Absolute URLs

    Nathan Sokalski, Aug 11, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    730
    Sriram Srivatsan
    Aug 12, 2008
  3. Adam Monsen

    JDBC URLs ...not really URLs?

    Adam Monsen, Feb 6, 2009, in forum: Java
    Replies:
    11
    Views:
    6,115
    Adam Monsen
    Feb 8, 2009
  4. Axel
    Replies:
    8
    Views:
    1,060
    Adrienne Boswell
    Apr 27, 2009
  5. jotto
    Replies:
    4
    Views:
    371
    jotto
    Oct 2, 2006
Loading...

Share This Page