tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikola Milutinovic" <>
Subject Re: JServ->Tomcat... <SERVLET> -> <jsp:info >... Servlets in jars
Date Wed, 28 Nov 2001 07:24:25 GMT
> I'm moving from JServ to Tomcat.
> I have all my servlets in jar files.
> I was using JSSI with JServ in order to use the <SERVLET 
>> Tag .
> how do I do this with tomcat now?  ( let me first say that I have been 
> searching for this information for about a week.)
> I can use the <jsp:include page=> tags for servlets that are not in 
> jars. but how do i use servlets in jars that are in the WEB-INF/classes dir?
> is there something special in the web.xml file?
> So how do i replace
> <SERVLET >   /* servlet in jar file */
>     <param name="name1" value="value1">
>     <param name="name2" value="value2">

First, the servlet has to be registered, as per Java Servlet 2.x specification in ./WEB-INF/web.xml:

  <!-- now the servlet has to be mapped to handle a URL request -->

After this, servlet container will forard all requests of the form "/servlet/some_path/Whatever/..."
to the servlet. Now you can use <jsp:include ...>.

> These servlets also need to be able to get the url params.

The servlet has access to the whole URL vie Servlet methods. See the specification.

> Also when I switched my old Stand alone servlets( <jsp:include page= > ) 
> to tomcat I noticed that I had to remove the out.close(); that was in 
> the servlet class file...  or tomcat would not be able to write the rest 
> of the jsp page.  This was not the behavior I observed on JServ and JRun.

Technically speaking, <jsp:include> which translates to a servlet's "include()" method,
just "borrows" the objects ServletRequest and ServletResponse to the included servlet. If
the included servlet closes the stream, normally, no-one after that can add anything. Why
would you explicitely need to close the output stream? If you want to flush the buffer than
just call "out.flush()".

View raw message