Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7191541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:45:02+00:00 2026-05-28T19:45:02+00:00

I need some advice on how I am using JQuery, JSP and Lucene to

  • 0

I need some advice on how I am using JQuery, JSP and Lucene to create my web application. I am not sure if I am doing it the correct way or if there is a better way I should be doing it. This is what I have:

When the user clicks on the search button I execute JQuery Ajax

$.ajax({
    url : "search.jsp",
    dataType:'json',
    data : "q=" + searchTerm,
        success : function(json) {
    var video = _.template($("#video_template").text());
    $.each(json, function(messageIndex, jsonObject) {
    var html = video({'_link': jsonObject.link, '_title': jsonObject.title, '_video': jsonObject.video});
    $("#search_results").append(html);
    });
    }
});

As you can see I go to search.jsp with my JQuery and return a json object which I use underscore.js to display the results.

This all works fine but I have a couple of questions.

Instead of using search.jsp, should I be using an HTTPServlet?
For example when I POST. Below I’ll have a collection of the search results which I can put into a JSON Object and send back to JQuery to display results

public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    String searchWord = request.getParameter("q");
    SearchManager searchManager = new SearchManager(searchWord);
    List searchResult = searchManager.search();
    RequestDispatcher dispatcher = request.getRequestDispatcher("index");
    request.setAttribute("searchResult", searchResult);
    dispatcher.forward(request, response);
}

At the moment I am only displaying 10 results, however I want to have a next button which the goes to my lucene application to get more results. The problem I have is that lucene will need to know about the search term and the number of results already there in order to display more. Is there a way I can hold onto a search object that knows about the current state of the search? Can JSON do this?

Hope someone can help. I used to Java and haven’t built a web application before.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:45:03+00:00Added an answer on May 28, 2026 at 7:45 pm

    Yes, you should definitely have your “real” Java code (like calling the Lucene API) in a Java class, not in the jsp.

    For simple cases and small applications, it’s perfectly fine to go with a servlet. But if your application will grow and become more complex in the future, you should probably rather switch to using a web/presentation tier framework. These frameworks will bring some ready-to-use features that you’d need to build on your own when working on the raw servlet API, and they will also enforce a better technical design of the application, which can greatly improve maintanabilty.

    For a scenario like the one above, it might make sense to go either for a REST services oriented framework like Jersey or any JAX-WS implementation, or you could use a framework that’s based on controller classes and the MVC pattern, like Spring MVC or Struts. These MVC frameworks might be the better choice if you want to also serve full HTML pages, not only JSON data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some advice on what route to go with. I'm using the jquery
I need some advice on creating a syntax highligher for java application using swing.
I need some advice from experts :) I will develop a website using PHP
I'm using a bit of jQuery to expand/hide some divs. I need to add
I have a regex problem that I need some advice on. I am using
I just need some advice about using tags. I'm working on a website right
Web Developer here and need some advice on how to achieve what must be
I need some advice about writing a parser (using C and Lex) that accepts
I need some advice please on the best way to achieve a particular outcome...
I need some advice as to how I easily can separate test runs for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.