5
I’m trying to find a way to provide a correct entry page in Jersey. A login page when there is no logged in user, otherwise I should display another homepage that will call Restful services developed with Jersey and that will change the interface of the home page when there is logged in user.
Below the file configuration web.xml
:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
Any solution is valid as long as it uses the web.xml
to facilitate. I don’t think it convenient to have to create a service to return each of these pages.
It doesn’t end up being more complicated to have to work with
Viewable
and create a class to return html content?web.xml
and regain aredirectTo()
for the first or second page?– Filipe
@Luizfilipe I usually do not use pure HTML but Jersey + Freemarker. Anyway, using a Servlet API Filter does not require working with Viewable.
– utluiz
even I know that it does not prevent, and you can be sure that Filter will be of great help, however my question is restricted in how to redirect between the pages that are in the configuration
<welcome-files-list>
– Filipe
@Luizfilipe Hum... I don’t know if I understand what you want. O
welcome-file-list
is not a list of site pages, but a list of default file names when the user accesses a URL without specifying the page. Using the question example, if the user type/app/pasta
in the URL, the server will search forindex.html
on the way/app/pasta/index.html
(from the app folder). If it does not find this file, then the server will search for/app/pasta/login.html
.– utluiz
@Luizfilipe If I’m understanding correctly, you must specify only
index.html
in web.xml and, in checking in the filter if the user is not logged in, redirecting it tologin.html
. If the login is successfully executed, then you redirect the user to theindex.html
or simply to the application’s base folder. If the login form checks with an Submit for a Servlet, just redirect. If login is done via Ajax, then you can usewindow.location.href
to redirect the user to the other page.– utluiz
This is a good solution!
– Filipe