Look for a book called Professional JSP. Chapter 6 has the best sample MVC
code I've seen yet. Used it as the basis for our framework, and we've been
very happy.

I've never bought the book and was able to find Chapter 6 online.

HTH

-----Original Message-----
From: John Smith [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 09, 2002 4:26 PM
To: [EMAIL PROTECTED]
Subject: Servlet Mapping issue


Hi,

I'm developing a system that relies on user
authentication. This is done with the MVC model using
a Controller servlet, beans
for communication and JSP pages for display.

I have done a basic system that does *part* of this
with normal JSP pages that are accessible in the
docroot, and the page/servlet
communication works fine. Once I'd got that working I
tried to apply some access controls by putting all the
JSP pages in the
WEB-INF directory (for protection - is there any
better way?) and routed all pages through the
Controller servlet as a
virtual path, so any page load is done like this:

        http://my.url.com/application/Controller/login.jsp

and then used the RequestDispatcher to direct them to
the appropriate page - no problems there, except the
page now has the
Controller servlet as the root of all it's references.
ie all relative links, images, etc now point to
my.url.com/application/Controller/xxx
whereas they should (or I would like them to) point to
my.url.com/application/xxxx. If the links are changed
to absolute paths,
the 'application' bit is ignored and so they end up
being my.url.com/xxxx, which is not what I want.

Obviously, I could fudge it and put
/application/images/title.gif (for example) in the JSP
page and be done with it, but what
if the webapp name changes? I don't want to sit there
replacing all the paths.

The example is an extremely brief overview of what I
mean, but to go into more detail would add another few
hundred lines ;)

This is one of the many problems I've faced so far in
dealing with MVC (which is a new concept to me being a
Perl/PHP programmer), but I want to move to Java as my
language of choice, and I would benefit greatly from
any REAL
example of a servlet/bean/JSP web app that:

        1. Doesn't use EJB
        2. Is at least complex enough to be able to cover
most, if not all, of the questions I have about MVC.
        3. Isn't some 'framework' to bung into your system.
        4. Might be some sort of Java-based opensource web
app like phpAds or phpMyAdmin, and use the MVC
paradigm.

So if anyone has any advice on the above, or has
pointers to code, or indeed code themselves, that may
help me understand a
little more, I'd greatly appreciate it.

Thanks,

James




__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to