See comments

Tom Gordon wrote:
>
> 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.

Yes. This is a problem. We started using Apache and JServ, and faced the
same problem. We tried an early version of Tomcat (first release of 3.0
AFAIK), but found problems with that too. We have settled on a
combination of Apache and Resin now, and that seems to work fine. Using
this we are able to use latest servlet API , JSP 1.1 and Java 2.

So no problems getting Model 2 to work.

All later comments are based on our setup, NOT on using JServ and the
earlier servlet API...
>
> 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.

request.setAttribute("something", new SomeObject());

>
> 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.

Not sure here, but check configuration of the webserver and servlet
engine before chucking out JSP/servlets as an option.

>
> 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.

This shouldn't be a problem. Check whether you are allowing cookies in
the browser you use - this is used for the session id.

>
> 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.

A controller jsp page IS essentially a servlet. Turn on "keep generated
pages", or whatever the equivalent option is in your servlet engine, and
check out what it generates. All it is doing is writing a servlet for
you :)

>
> Yes, I should use a platform that supports the latest API, but for some
> people, it takes a while to upgrade for various reasons.
>

It may well be easier for you to convince "the powers that be" or
whoever/whatever is standing in the way of an upgrade.

--
Jari Worsley
Senior Programmer
Hyperlink plc

===========================================================================
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