• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using Lucene/servlets/jsps

 
Nicole Jones
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2839
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2839
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic