aspose file tools*
The moose likes Other Open Source Projects and the fly likes using Lucene/servlets/jsps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "using Lucene/servlets/jsps" Watch "using Lucene/servlets/jsps" New topic
Author

using Lucene/servlets/jsps

Nicole Jones
Greenhorn

Joined: Mar 18, 2011
Posts: 21
is anyone here familiar with lucene/servlets/jsps?

if so, i need some guidance. i have successfully indexed content and have a servlet that searches through a lucene index and returns hit documents in a table format via a jsp. the hit documents contain highlighted content so that the users eye can quickly jump to the keyword specified. is it possible to pass the highlighted term to another jsp? or does the jsp have to have access to the lucene attribute (for example: session.setAttribute("searchResult", searchResult); ) via the search servlet?

i hope this makes sense. any help is greatly appreciated!
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I don't think I understand the problem. If the search results are in the session, then any servlet or JSP can get at it. But yes, it needs to be stored somewhere in order for other parts of the web app to access it.
Nicole Jones
Greenhorn

Joined: Mar 18, 2011
Posts: 21
Thanks Tim.

Lets say, for instance, I enter a keyword. The servlet returns the results in a table format with the keyword highlighted (in this case, a title). I click on the highlighted title, which takes me to a detail page (JSP). i want the detail page to display the highlighted keyword within the title. does the search session have to be forwarded to that detail page? or can i simply access it like so ${result.title} without having to forward the search session to the detail page?

Tim Moores wrote:I don't think I understand the problem. If the search results are in the session, then any servlet or JSP can get at it. But yes, it needs to be stored somewhere in order for other parts of the web app to access it.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I think you're confused about terminology - a session is not "forwarded". While I think I know what you mean, it needs to be said that "forwarding" has a specific meaning in the servlet/JSP context, and it's not what you're talking about.

In order to be able to access ${result.title} in a JSP, "result" needs to be set as an attribute in some context accessible to a JSP - that can be the web app context, it can be the session, it can be the request, or it can be the page. Doesn't matter which one, as the JSP will look in all those contexts. (And when I say "doesn't matter", I'm not saying that all contexts are equal - they're not. I'm just saying that the JSP will look in all of them in order to find that attribute.)

But as I said before - it doesn't happen automatically, you need to set that object as an attribute in one of those contexts.
 
 
subject: using Lucene/servlets/jsps
 
Similar Threads
Architecture question
which book to refer for servlets as a beginner
A Question on Lucene
good editor
portlet