Stefan Freyr Stefansson wrote:
>
> Hi.
>
> I'm new to JSP and all that so I wanted to post this question, sorry if
> you've covered it all before and stuff.
>
> I want to know if theres something that says that making an "empty" JSP page
> (by empty I mean one with no HTML tags or output) is a bad thing.  I know I
> could write a servlet but I think it's more convenient to write a JSP page.
>
> In case you don't understand what I'm talking about, let me explain:
> I have this page where I enter information.  I enter it into a form and then
> when the form is submitted I call a JSP page which redirects me to the
> "success" or "no success" page.  In other words, this JSP page doesn't show
> any result by itself, It only performs some tasks (like creating a UIHandler
> object which creates a SQLGenerator object which uses the DBInterface object
> to write to the database) and then redirects.
>
> Is this something that's not preferred?  Should I have the message
> ("success" or "no success") inside the doRegister.jsp page instead of having
> it redirect?  What say y'all?

The answer is, as it often is with architecture questions, that it depends ;-)

If you have to put a lot of code in the page you submit to, it's usually
better to make it a real servlet that forwards to a JSP page for presentation.
One reason is that it's usually easier to debug a hand coded servlet in an IDE
than a servlet from a JSP.

If the code is trivial, and you don't want to write a servlet for some reason,
I recommend the approach you use. This way the request processing code is
separated
from the presentation. You can change the layout of the presentation pages
without
introducing errors in the processing logic. It also makes it easier to move to
a servlet "front component" model later if you wish.

If the test code is extremely simple, and can be described more as presentation
logic (e.g. say "Good morning" or "Good evening" depending on the time of day),
it may be better to include it in the presentation page.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to