Re: Getting JSP to work in 6.1

"Daniel P. Berrange" <[email protected]> Thu, 29 Apr 2004 11:18:53 +0100
Newsgroups gmane.linux.redhat.ccm.general
Message-ID <[email protected]>
On Wed, Apr 28, 2004 at 10:53:36PM -0400, Jeff Hoffman wrote:
> Hello,
> 
> I am trying to get a "Hello, world!"-type JSP application up and running 
> on 6.1. I have done the following:
> 
> 1. Created a project called 'myjspapp'.
> 
> 2. Placed a web.xml file in myjspapp/myjspapp/web/WEB-INF.
> 
> 3. Created a loader to create an instance of my app on /ccm/myjspapp.
> 
> 4. Tested that it worked with my own servlet, much like the Binder 
> example's servlet (just a simple output.)
> 
> 5. Changed to the JSPApplicationDispatcher in web.xml:
> 
> ...
> <servlet>
>    <servlet-name>myjspapp</servlet-name>
>  
> <servlet-class>com.arsdigita.dispatcher.JSPApplicationDispatcher</servlet-class>
> </servlet>
> 
> <servlet-mapping>
>    <servlet-name>myjspapp</servlet-name>
>    <url-pattern>/*</url-pattern>
> </servlet-mapping>
> ...
> 
> 6. Placed a JSP file in myjspapp/myjspapp/web/index.jsp
> 
> 7. I get the following error when pulling /ccm/myjspapp/index.jsp:
> 
> 404 Not Found
> 
> /myjspapp/__ccm__/servlet/legacy-adapter/ was not found on this server.

The base implementation of the c.a.web.Application class is setup for 
legacy SiteNode / PackageInstance support - so requests will be served
from the root webapp with your Dispatcher implementation. This is obviously
not what you want for new applications, so in your subclass of Application
you need to override the methods:

    public String getContextPath() {
       return "/ccm-ldn-terms";
    }
		    
    public String getServletPath() {
       return "/files";
    }

The 'getContextPath' should return the name of your private webapp
deployment directory (as specified in the name attribute in your
application.xml file).

The 'getServletPath' should return the path of the main servlet
mapping in your web.xml - in your case since you've mapped in
to '/' i believe you just need to return '' (ie empty string).

One tip I'd recommend is to not use the JSPApplicationDispatcher,
but instead use 'c.a.web.ApplicationFileServlet' and map it into
'/files/*'. Take a look at any of the APLAWS+ applications[1] for
examples of this in practice - in particular the 'ccm-ldn-terms'
application is the one I consider to be closest to 'ideal best
practice'.

Also, don't forget to add in a declaration for the 
com.arsdigita.web.ContextRegistrationServlet in your web.xml

Dan.

[1] Download source for these from aplaws.sourceforge.net
-- 
|=-             Daniel P. Berrange  -  [email protected]              -=|
|=-   Red Hat, 338 Euston Road, London, NW1 3BT.  +44 (0)7977 267 243   -=|
|=-                                                                     -=|
|=- GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

-- 
Redhat-ccm-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/redhat-ccm-list
Archives: https://www.redhat.com/pipermail/redhat-ccm-list/
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQFAkNaNs9/3Qn07lQURAlntAJ9zzOqTKl1uGZExQbYi8J1FYbWHPACgl2EJ
VP7e1LtxIpOHP6Se1mELUY0=
=ac+b
-----END PGP SIGNATURE-----