Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

RE: Retrieving the context path from a standalone class

Shapira, Yoav

2004-01-08

Replies:


Howdy,

>If
>it isn't then I want to know the correct way to deal with the problem.

Can you restate your problem? If I remember correctly, it was that you
need to index your site using lucene upon tomcat startup. You don't
want to wait for the first user request because you don't want that
request to have to wait for indexing. Is that right?

>The only thing I didn't understand in your email was the comment re
>docBase.
>I'm not sure what this is - in particular, are you talking HTML
document
>base or some other mechanism - can you enlighten me?

The docBase is the root directory of your webapplication, i.e.
/contextPath/. It's not the same as the root directory of the server
usually, only in the special case where contextPath is the empty string.
All ServletContext#getResource and getRequestDispatcher calls are
relative to this docBase rather than the server root, and therefore you
don't need to know the context path in order to use these function
calls.

>Actually I just thought of another argument for supplying deployment
>information to the developer - feel free to shoot me down. In my web
app I
>have a filter called ProtocolFilter. It simply switches the client in
and
>out of SSL as specified by filter options. In order to perform the
switch,
>the ports must be known. I currently have these ports defined as env
>entries
>so that the filter (and other code) can pick them up. How else could I
>possibly do this?

Using the redirectPort attribute of tomcat's Connector element in
server.xml.

I took a look at lucene's indexing code. It seems like you can
construct an Analyzer from a Reader (so an InputStreamReader constructed
from the InputStream returned by ServletContext#getResourceAsStream
would work), and then use a RAMDirectory as the IndexWriter's Directory
argument. Alternatively you an use an FSDirectory if you want to save
the index to disk, use the one directory where the container will let
you write, the directory accessible via (File)
servletContext.getAttribute("javax.servlet.context.tempdir");
That should work, no?

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.