aspose file tools*
The moose likes Struts and the fly likes switching to HTTPS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "switching to HTTPS" Watch "switching to HTTPS" New topic
Author

switching to HTTPS

Bhaskar Reddy
Ranch Hand

Joined: Dec 17, 2002
Posts: 52
Hi Folks,

I am trying to switch from 'http' request to 'https' after successful registration process.
In my struts-config file, I have something like this -


In my RegistrationAction.java, I have the following -

public ActionForward doExecute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws Exception {
// stuff1...
// stuff2...

return actionMapping.findForward("success");
}

I have a method that can generate the 'https' URL (as String) based on actionForward. But I am not sure as to how can I use this in my ActionClass as the ActionClass must return actionForward...

Any help on this is much appreciated.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You can also create an ActionForward from a constructor. Here's an example of what you might do:


[ November 13, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Bhaskar Reddy
Ranch Hand

Joined: Dec 17, 2002
Posts: 52
Thank you Merrill for your prompt and useful reply!

But I guess, I am stuck in the myMethodThatTransformsToSSL(regularURL) method! I assumed that I'd be able to construct the entire URL by using the methods in the request object (like getRequestURL or something) but I am not able to get this working with the tiles definition.

Could you let me know how do I set up the URL with 'https' and forward/redirect it to the content page of tiles definition?

I came across the sslext library (from sourceforge) but since our application already is in alpha testing, I didnt want to go that route...
[ November 13, 2007: Message edited by: Bhaskar Reddy ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Since you're changing protocols (http to https) you must redirect to a new URL rather than simply forwarding to it. Since you're using tiles, this means redisplaying the tiles template. Since the current request is only for the current page fragment, I don't know of a way to dynamically get the name of the tiles template being displayed. You may have to hard code it.

I'd still get the server portion of the URL using the reqeust.getRequestURI() method. Then change http to https and plug in the tiles template.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: switching to HTTPS