lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Linwood <>
Subject Re: [NEWBIE] Creating context-relative URLs with Tomcat + Struts
Date Wed, 10 Sep 2003 05:40:48 GMT
Why don't you set the path field to be relative to whatever the base 
directory is that the administrator puts in?  So, you write the path 
field yourself, and just put in the relative link, like /index.jsp, 
/welcome.jsp, or whatever?  You can just use the relative link directly 
in your web application.

The book chapter covers pulling content out of a database through a data 
access layer, so it's a little different than pulling files out of a 
file system, but most of the basics are the same.

If the actual content is hidden behind wrapper JSP pages, Struts 
Actions, parameters, or whatever, the display code that writes the links 
out in the JSP page can reference a mapping like you said.  The hard 
part would be writing the mapping code, calling it should be easy.

Hope this helps,

Marco Tedone wrote:
> Hi Jeff, DAMN!, two of the books I haven't got :) I bought Jakarta Struts
> from O'reilly and another one on JSP/Servlets/Web programming.
> I already wrote the user interfaces and the classes (I wrote a stateless EJB
> which performs both the indexing and the researching of the result) to run
> the search.
> My problem is another: as you'll certainly know, as I'm running on Windows,
> my Tomcat home path is something similar to:
> D:\Tomcat\
>>From my web application (which is a J2EE application using Struts and
> Tomcat) I ask the application administrator to specify the folder she wants
> to index and the folder where she wants the results to be put (for future
> searches...) and the file extensions she wants to include.
> Now, the application generates the index without any problem. The problem is
> that the path to the files is:
> D:\Tomcat\webapps\myapp\web\.... (The list of indexed files) and not
> something like:
> ...And so on.
> Therefore, if the user runs a search, I feel myself ridicolous if I'm going
> to show her Windows path instead of web-relative paths. The reason for that
> is that I'm using the FileDocument class coming with the distribution, which
> write the "path" Field using the File.getPath() method.
> But there is another problem: because I'm using Tiles (a mean of framing)
> the actual web-content is contained in foo-body.jsp pages, which are not
> directly accessible, because at least the user will access foo.jsp (which
> basically contains only an include to the foo-body.jsp) but more likely he
> will perform a Struts Action.
> I'm thinking at the following possible solution:
> Defining somewhere (conf file?) a mapping between paths to JSPs containing
> sensible content (i.e. referring to the above example foo-body.jsp. This way
> the path could remain system-relative) and URLs to Struts Action which are
> actually executable by simply clicking a link and which forward to those
> JSPs. The user then will perform a search, my application will intercept the
> string representing the path to the document containing the information,
> will search on the mapping file the mapping to the Struts action and will
> display to the user the latter link. Eventually the results can be cached
> somewhere.
> What do you think about this possible solution?
> Marco

View raw message