You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Marco Tedone <mt...@jemos.org> on 2003/09/07 19:59:40 UTC

[NEWBIE] Creating context-relative URLs with Tomcat + Struts

Hi all, this is my first post, so I hope not to bore you too much with my
questions:

Ok, let's say that I would like to translate system's specific URLs (i.e.
D:\Tomcat\webapps\foo\foo\bar.jsp and so on...) into  web-context specific
URLs (i.e. http://myServer/foo/foo/bar.jsp). Well, if I immagine to replace
D:\Tomcat\webapps with http://myServer things seem quite easy. My first
question is: is this the right way? As I am very new to Lucene, is there a
possibility to instruct the IndexWriter to replace system path with web path
(specified as argument) during index creation?

Secondly, this is for Struts users, a jsp page not necessarily can be
executed without passing from a Struts Action (i.e. an Action prepared some
data to display, and if we try to access the jsp directly we could have some
bad 5 minutes), so my question is: did anyone encountered this kind of
questions? Did you find any solution? For this second subject, I could think
to a sort of mapping file between JSPs and relevant actions, so that we can
assume that if the user clicks on a JSP link, instead the relevant action
for that JSP will be executed and then the JSP displayed. The mainteinance
for this solution seems CRAP.

Hope someone of you will help,

Marco




Re: [NEWBIE] Creating context-relative URLs with Tomcat + Struts

Posted by Marco Tedone <mt...@jemos.org>.
Jeff, that exactly what I'm realizing.

First of all I have been able to read the configuration file (by keeping an
instance of ModuleConfig at startup) and therefore to realize a mapping
between (action -> JSP). This has been only possible because even for simple
forwards I used the Struts ForwardAction. I also found the way to isolate:
protocol + server | web-app-context | action/jsp | Servlet mapping (.do /
/action/).

In the meantime, I created a stateless session bean which has a method
which, given an environment variable as a String, returns the path to that
environment variable; therefore it will be quite simple to replace, let's
say, CATALINA_HOME with the information I isolated as mentioned above.

I'm going to create an entity bean (therefore a db table) with the isolated
information (i.e. protocol, context, and so on);
when user will run a search, and possibly Lucene will return to me the list
of system-relative JSPs, I'll substitute the system-path with the web-path,
by concatenating all the web-relative information stored in the database,
and instead of presenting to the user the list of links to JSPs, I'll show
him the list of links to actions.

There is still a major problem to solve; realize somehow the mapping between
actual content-matching JSPs and JSPs which define only Tiles 'define'
statements. The reason is that the JSPs mapped vs an action in the struts
configuration file are basically empty.

I'll have to work around it.

Marco

- Original Message ----- 
From: "Jeff Linwood" <je...@greenninja.com>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Wednesday, September 10, 2003 6:40 AM
Subject: Re: [NEWBIE] Creating context-relative URLs with Tomcat + Struts


> 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,
> Jeff
>
> 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:
> >
> > http://www.jemos.org/myapp/web/index.jsp
> > http://www.jemos.org/myapp/web/welcome.jsp
> >
> > ...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
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>




Re: [NEWBIE] Creating context-relative URLs with Tomcat + Struts

Posted by Jeff Linwood <je...@greenninja.com>.
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,
Jeff

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:
> 
> http://www.jemos.org/myapp/web/index.jsp
> http://www.jemos.org/myapp/web/welcome.jsp
> 
> ...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
> 


Re: [NEWBIE] Creating context-relative URLs with Tomcat + Struts

Posted by Marco Tedone <mt...@jemos.org>.
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\

Re: [NEWBIE] Creating context-relative URLs with Tomcat + Struts

Posted by Jeff Linwood <je...@greenninja.com>.
Hi,

I don't know of any books on just Lucene, but I wrote a chapter on Lucene in
Professional Struts Applications. Since you're apparently using Struts, you
might find it useful.  Another book that has a chapter on Lucene is
Professional JSP.

One thing you should know about Lucene - it's not a ready-to-run search
engine.  You can't just drop it into a web application and let it go, you
have to write the code to add the content to Lucene yourself, and write the
web pages to search the Lucene index and display the results.

Thanks,
Jeff
----- Original Message ----- 
From: "Marco Tedone" <mt...@jemos.org>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Monday, September 08, 2003 1:42 AM
Subject: Re: [NEWBIE] Creating context-relative URLs with Tomcat + Struts


> Sorry Scott, I was under the flies of enthusiasm :)  I'm trying to realize
a
> simple web-site search functionality and I would like to use Lucene as
> index-search engine.
>
> BTW, does it exist any book on Lucene?
>
> Marco
> ----- Original Message ----- 
> From: "Scott Farquhar" <sc...@atlassian.com>
> To: "Lucene Users List" <lu...@jakarta.apache.org>
> Sent: Monday, September 08, 2003 12:21 AM
> Subject: Re: [NEWBIE] Creating context-relative URLs with Tomcat + Struts
>
>
> > Marco,
> >
> > You may want to explain what you are trying to do before you start
> > describing your problems.
> >
> > For example, I have no idea how / why you would use Lucene to do either
> > of the things you are talking about below.
> >
> > Cheers,
> > Scott
> >
> > On Sun, Sep 07, 2003 at 06:59:40PM +0100, Marco Tedone wrote:
> > > Hi all, this is my first post, so I hope not to bore you too much with
> my
> > > questions:
> > >
> > > Ok, let's say that I would like to translate system's specific URLs
> (i.e.
> > > D:\Tomcat\webapps\foo\foo\bar.jsp and so on...) into  web-context
> specific
> > > URLs (i.e. http://myServer/foo/foo/bar.jsp). Well, if I immagine to
> replace
> > > D:\Tomcat\webapps with http://myServer things seem quite easy. My
first
> > > question is: is this the right way? As I am very new to Lucene, is
there
> a
> > > possibility to instruct the IndexWriter to replace system path with
web
> path
> > > (specified as argument) during index creation?
> > >
> > > Secondly, this is for Struts users, a jsp page not necessarily can be
> > > executed without passing from a Struts Action (i.e. an Action prepared
> some
> > > data to display, and if we try to access the jsp directly we could
have
> some
> > > bad 5 minutes), so my question is: did anyone encountered this kind of
> > > questions? Did you find any solution? For this second subject, I could
> think
> > > to a sort of mapping file between JSPs and relevant actions, so that
we
> can
> > > assume that if the user clicks on a JSP link, instead the relevant
> action
> > > for that JSP will be executed and then the JSP displayed. The
> mainteinance
> > > for this solution seems CRAP.
> > >
> > > Hope someone of you will help,
> > >
> > > Marco
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> >
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>


Re: [NEWBIE] Creating context-relative URLs with Tomcat + Struts

Posted by Marco Tedone <mt...@jemos.org>.
Sorry Scott, I was under the flies of enthusiasm :)  I'm trying to realize a
simple web-site search functionality and I would like to use Lucene as
index-search engine.

BTW, does it exist any book on Lucene?

Marco
----- Original Message ----- 
From: "Scott Farquhar" <sc...@atlassian.com>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Monday, September 08, 2003 12:21 AM
Subject: Re: [NEWBIE] Creating context-relative URLs with Tomcat + Struts


> Marco,
>
> You may want to explain what you are trying to do before you start
> describing your problems.
>
> For example, I have no idea how / why you would use Lucene to do either
> of the things you are talking about below.
>
> Cheers,
> Scott
>
> On Sun, Sep 07, 2003 at 06:59:40PM +0100, Marco Tedone wrote:
> > Hi all, this is my first post, so I hope not to bore you too much with
my
> > questions:
> >
> > Ok, let's say that I would like to translate system's specific URLs
(i.e.
> > D:\Tomcat\webapps\foo\foo\bar.jsp and so on...) into  web-context
specific
> > URLs (i.e. http://myServer/foo/foo/bar.jsp). Well, if I immagine to
replace
> > D:\Tomcat\webapps with http://myServer things seem quite easy. My first
> > question is: is this the right way? As I am very new to Lucene, is there
a
> > possibility to instruct the IndexWriter to replace system path with web
path
> > (specified as argument) during index creation?
> >
> > Secondly, this is for Struts users, a jsp page not necessarily can be
> > executed without passing from a Struts Action (i.e. an Action prepared
some
> > data to display, and if we try to access the jsp directly we could have
some
> > bad 5 minutes), so my question is: did anyone encountered this kind of
> > questions? Did you find any solution? For this second subject, I could
think
> > to a sort of mapping file between JSPs and relevant actions, so that we
can
> > assume that if the user clicks on a JSP link, instead the relevant
action
> > for that JSP will be executed and then the JSP displayed. The
mainteinance
> > for this solution seems CRAP.
> >
> > Hope someone of you will help,
> >
> > Marco
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>




Re: [NEWBIE] Creating context-relative URLs with Tomcat + Struts

Posted by Scott Farquhar <sc...@atlassian.com>.
Marco,

You may want to explain what you are trying to do before you start
describing your problems.

For example, I have no idea how / why you would use Lucene to do either
of the things you are talking about below.

Cheers,
Scott

On Sun, Sep 07, 2003 at 06:59:40PM +0100, Marco Tedone wrote:
> Hi all, this is my first post, so I hope not to bore you too much with my
> questions:
> 
> Ok, let's say that I would like to translate system's specific URLs (i.e.
> D:\Tomcat\webapps\foo\foo\bar.jsp and so on...) into  web-context specific
> URLs (i.e. http://myServer/foo/foo/bar.jsp). Well, if I immagine to replace
> D:\Tomcat\webapps with http://myServer things seem quite easy. My first
> question is: is this the right way? As I am very new to Lucene, is there a
> possibility to instruct the IndexWriter to replace system path with web path
> (specified as argument) during index creation?
> 
> Secondly, this is for Struts users, a jsp page not necessarily can be
> executed without passing from a Struts Action (i.e. an Action prepared some
> data to display, and if we try to access the jsp directly we could have some
> bad 5 minutes), so my question is: did anyone encountered this kind of
> questions? Did you find any solution? For this second subject, I could think
> to a sort of mapping file between JSPs and relevant actions, so that we can
> assume that if the user clicks on a JSP link, instead the relevant action
> for that JSP will be executed and then the JSP displayed. The mainteinance
> for this solution seems CRAP.
> 
> Hope someone of you will help,
> 
> Marco
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org