This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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..
Joined: Sep 10, 2002
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?
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...
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 ]
Joined: Aug 08, 2005
Excellent! I hadn't caught that in the question (when I should have) that Murat asked...
Joined: Sep 10, 2002
Marie Pierre, Thats what I was looking for. Thank you Murat
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 ]