I just wanted to warn people of a possible gotcha in moving to the model
2 pattern. Perhaps people can correct me if I'm wrong, also. It seems
to me that the model 2 pattern doesn't really work with the servlet 2.0
API.
I recently tried to implement a model 2 pattern, but had to back off. I
was using Apache + JServ, which has servlet 2.0 API support, and GNU
JSP.
First of all, there is no RequestDispatcher in 2.0. Yuck.
Second, I didn't see any way, from the servlet, to store beans or any
other object in the request object, only in the session object.
Third, I could not access jsp or html pages in the same directory as the
servlet. For example, I created a servlet zone /myservlet. I could
access /myservlet/MyServletClass, but when MyServletClass redirected to
/myservlet/results.jsp, the jsp page would show up, but no links would
show up (such as images). I could not access /myservlet/somepage.html
directly from the browser.
Fourth, every time I hit the servlet and got the session, it was a
completely new session. I have no idea why this would be the case.
This was why I had to give up using a servlet completely.
To get around this, but in the spirit of separation of java from html, I
am using controller jsp pages. I don't know why these work instead of a
servlet. Maybe I didn't set up apache correctly, or maybe it's the
combination of apache/JServ/gnujsp. Essentially, the action attribute
of a form points to a jsp page, which in turn does validation, talks to
the server proxy, and redirects to the appropriate response page.
Anyway, I like the controller jsp pages, even if it's a cheap way of
doing a controller servlet. You still get most java code in one page
and most html display code in a separate page. I just stuck a server
proxy object in the session so that all pages could reuse it.
Yes, I should use a platform that supports the latest API, but for some
people, it takes a while to upgrade for various reasons.
-Tom
===========================================================================
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