tags:

views:

358

answers:

1

Hi,

I have a bit of an issue for my JSP site.

I have it divided into three sections: a main folder within which a "resources" and an "actions" folder are. I house the files which show the site in the main folder, and validaton and action files in the "actions" folder.

Upon entering a site, a user must login. I validate whether a user is registered and their password is valid via a script in "actions". From this script, I jsp:forward the appropriate script for the user's login information, that is, the login screen if it is invalid, or the home page if it is valid.

It startles me when, by jsp:forwarding the home page, it can't access the CSS as it thought it was still in the "actions" directory, whereas I know it is in the main folder and thus could access a file within the "resources" folder via "./resources/".

My question is, can I use another mechanism to set the page to the home page, or am I limited to using jsp:forward and thus have to deal with the relative URLs thinking we are in "actions"?

Thanks for any advice!

+1  A: 

Could you redirect rather than forward? That would make the URL match the location of the destination page:

response.sendRedirect('url');
RichieHindle
Do you know how I could do that?
Beau Martínez
I've added the example code to my answer.
RichieHindle
By sending any content, does this refer to out.print()?
Beau Martínez
The sendRedirect() has to be the first (and only) thing the page does, before anything gets sent to the browser. out.print() is one way of sending to the browser, but simply having any HTML content before the sendRedirect() is another. Having a 'return;' statement after the sendRedirect() is probably a good idea too.
RichieHindle