Handling the user visiting the V in MVC first

J

Jeffrey.Rodriguez

While I am new to Java, I believe I understand how MVC works and how to
program for it. However, what I'm not sure of is what to do if a user
goes directly to the JSP page (the view).

Is there a standard way of handling this? My thought would be to test
if the model components are there, if not, forward to the controller to
setup the model, then forward BACK to the original view jsp page.

Is there an easy way to do this with a minimum amount of code, or am I
going about it completely wrong?
 
W

Wendy Smoak

While I am new to Java, I believe I understand how MVC works and how to
program for it. However, what I'm not sure of is what to do if a user
goes directly to the JSP page (the view).

The easiest way to handle it is to never let it happen in the first place.
Protect your JSPs from direct access and force the user to go through the
controller.
 
O

Oscar kind

While I am new to Java, I believe I understand how MVC works and how to
program for it. However, what I'm not sure of is what to do if a user
goes directly to the JSP page (the view).

Is there a standard way of handling this? My thought would be to test
if the model components are there, if not, forward to the controller to
setup the model, then forward BACK to the original view jsp page.

Is there an easy way to do this with a minimum amount of code, or am I
going about it completely wrong?

You can do this without code, by using authentication and authorization:
the JSP pages require a role that noone has.

Another option is to put the JSP pages in WEB-INF, and reference them from
there. This option doesn't work with Java Server Faces though.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top