wood burning stoves 2.0*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes MVC question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "MVC question" Watch "MVC question" New topic
Author

MVC question

Murat Balkan
Ranch Hand

Joined: Sep 10, 2002
Posts: 127
Hi,
I have a question about mvc commands.
When displaying a login page or something like that where no business logic is required how do you model the MVC part?
Do I have to place dummy controller methods for this that only returns the next view?
Thank you for your help
Murat
jason white
Ranch Hand

Joined: Aug 08, 2005
Posts: 60
Murat,

You asked: When displaying a login page or something like that where no business logic is required how do you model the MVC part?

I would implement this using a static hmtl page which calls a authentication servlet which then controls the workflow etc.. to return an error page or the application in whatever capacity. I would model the login page as a static html page which interacts with a servlet, with then posts a jsp page or static html page...

Hopefully this answers your question..

-jason
Murat Balkan
Ranch Hand

Joined: Sep 10, 2002
Posts: 127
Hi ,
Thanks for your response.
Consider I have a static html login page.
User types http://x.com/myapp/login.htm
but on the server side theres a frontcontroller for /myapp so it has to go through the FC. Here FC has to "execute" something and return the next url.
so there has to be a method that is command, that does nothing I think.
Am I wrong?
jason white
Ranch Hand

Joined: Aug 08, 2005
Posts: 60
Murat,

I guess I am getting a little confused...

"User types http://x.com/myapp/login.htm
but on the server side theres a frontcontroller for /myapp so it has to go through the FC."


For static html requests, why would your FC be involved at all? Think of it another way, if I am using Struts, do I put any action mappings in the struts-config.xml in order to GET to the html page? I usually put them in to map behavior for that page based on actions executed by the user..


"so there has to be a method that is command, that does nothing I think."

Your command, called via execute() (after the user interacts with the html page) I am guessing (from the FC), definately does something right? I would have that command attempt to authenticate the user...then, based on authentication or lack thereof, I would return a specific url through the FC...


So, in my humble opinion, I would model this part of the solution as a static html page which exists outside of the Front Controller framework. This is similar in struts or a simple web application also.

If you are intercepting a basic http request to serve a static page and wanting to do some specific back-end logic then maybe interacting with the FC is a great solution. For me though, it would be overkill....

Please let me know if I addressed your question well...

-jason
Marie Pierre Courbevoie
Ranch Hand

Joined: Aug 01, 2005
Posts: 32
Murat

Don't map /myApp/ to your servlet controller , instead use something like /myApp/*.do .
In your forms, action may be: seachFlights.do, bookSeats.do.....
"*" may be any action in your action mapping configuration file.
All urls not ending with ".do" are ignored by the controller
You may also use a ServletFilter which dispatches all non authenticated user requests to a login page for exemple, a ServletFilter is useful for a wide range of preprocessing operations. For server managed security let the server redirect the user to a login page
You have a wide range of choices

Marie Pierre
[ August 15, 2005: Message edited by: Marie Pierre Courbevoie ]
jason white
Ranch Hand

Joined: Aug 08, 2005
Posts: 60
Marie Pierre,

Excellent! I hadn't caught that in the question (when I should have) that Murat asked...

-jason
Murat Balkan
Ranch Hand

Joined: Sep 10, 2002
Posts: 127
Marie Pierre,
Thats what I was looking for.
Thank you
Murat
Chintan Rajyaguru
Ranch Hand

Joined: Aug 19, 2001
Posts: 341
Marie's point is completely valid. I just wanted to add a comment (not related to your modeling question though) that in real world, you should have all static content (htmls and images) served by the web server (e.g. IIS or apache), which runs on the firewall. This saves an unnecessary trip to the application server (e.g. WebSphere). A plugin that is configured on the web server determines when a request should be forwarded to the application server (typically using Marie's technique).

An authentication service agent (e.g. siteminder agent) may run on the web server to authenticate every request OR a filter may run on the application server to intercept all the requests and authenticate them.

If I were doing the assignment (which I am not), I would do something like this to mirror the real world applications.
[ August 16, 2005: Message edited by: Chintan Rajyaguru ]

ChintanRajyaguru.com
SOADevelopment.com - Coming soon!
 
wood burning stoves
 
subject: MVC question