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 9081121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:14:19+00:00 2026-06-16T20:14:19+00:00

So I have this JSP search function as you can see below: <% String

  • 0

So I have this JSP search function as you can see below:

<%
String value=request.getParameter("search");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://instance****.db.xeround.com:*****/mydb", "*****", "*******");
Statement st=conn.createStatement();
ResultSet rs = st.executeQuery("SELECT menu.name, menu.info, menu.price, restaurants.name from menu,"
        + " restaurants where restaurants_restaurantID=RestaurantID AND (menu.name like '%"
        + value
        + "%' "
        + "or menu.info like '%"
        + value
        + "%' or menu.category like '%"
        + value
        + "%' "
        + "or menu.kitchen like '%"
        + value
        + "%' or quick_choose like '%" + value + "%')");

while (rs.next()){ 
    %>
<tr><td>Name:</td><td><input type="text" value="<%=rs.getString("name")%>" > </td></tr>
<tr><td>Info:</td><td><input type="text" value="<%=rs.getString("info")%>" > </td></tr>
<tr><td>Price:</td><td><input type="text" value="<%=rs.getInt("price")%>" > </td></tr>
      <%
}
%>

This is working and pulling the info I need from the database, but what I want to do right now is to somehow make the results line up correctly as in that each result line will display only the name/dish description/price for one food. also I want it to work With a top header that looks like this: Here

Where the results displays under the header Restaurant, Dish, Type, Price. So that they displays correctly under those titles.

And then divide each line with a line. Such as in facebook when you go and search something, the results will be shown and divided by a thin line.

Same as the link above and Shown here:
the line

Summary for those who don’t wanna read too much: I basically want my search results to be like this site:Here, under a header devided into different colums and have a line that separates each search result.

Do any of you know any possible solution for this in HTML? Or can give me any advice on how to preceed? I’ve tried a few alternatives but I just can’t figure it out. Would really appraciate any help or guidance. Thank you so much.

  • 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-06-16T20:14:20+00:00Added an answer on June 16, 2026 at 8:14 pm

    Necessary to you html:

    <table>
      <tr class="head">
        <td>Name:</td>
        <td>Info:</td>
        <td>Price:</td>
      </tr>    
    <%
     while (rs.next()){ 
    %>
      <tr class="content">
        <td class="name"><%=rs.getString("name")%></td>
        <td class="info"><%=rs.getString("info")%></td>
        <td class="price"><%=rs.getInt("price")%></td>
      </tr>
    <%
     }
    %>
    </table>
    

    and approximate css:

    table {
        border-collapse: collapse;
    }
    .head td {
        text-align: center;
    }
    .content td {
        padding: 5px 10px;
        vertical-align: top;
        text-align: left;
        border-bottom: 1px solid #C0C0C0;
        border-bottom-style: dotted;
    }
    .info {
        background-color: #F1F4F6;
    }
    

    But first, scriptlets is very poor practice. Secondly, getting of database connection in JSP is shot in the head.
    Your JSP page should be responsible only for view. Replace your code into separate Java classes. Otherwise, when your code will bloat your project will be unreadable and bad maintainable.

    Using JSTL you can get easily the same view:

    <c:forEach var="item" items="${requestScope.items}">
       <div id="item_title" class="item_title">
          <a href="${pageContext.request.contextPath}${item.url}">
            <c:out value="${item.title}" />
          </a>
       </div>
       <div id="item_content" class="item_content">
          <c:out value"${item.content}" />
       </div>
    <c:forEach>
    

    or

       <div id="item_title" class="item_title">
          <form name="openItem" action="handlerurl" method="post">
            <input type="hidden" name="itemId" value="${item.id}" />
            <c:out value="${item.title}" />
            <input type="submit" value="read more" />
          </form>
       </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this JSP code snippet: <%@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c%> <c:choose> <c:when test=${var1.properties[\Item Type\]
I have this jQuery code in my JSP page (jQuery 1.7.2) : function Header()
i have this tag as input tag: <a href=controller.jsp?sid=127490C88DB5&R=35144 class=11-link-dkred-bold><b>Mr. John Q. Anderson&nbsp;&nbsp;&nbsp;MBA 1977
I have a JSP page at an address like this: http://example.com/foo/bar/rawr/something.jsp When I output
I have the following form from http://regain.sourceforge.net/ : <form name=search action=search.jsp method=get> <p class=searchinput>
Suppose I have JS code inside a jsp files, such as this: <% String
I have a simple search page with this text input form <form name=assetInput action=assetResult.jsp
I have this Controller : @Controller @RequestMapping(/path/*) public class MyController { @RequestMapping(value = /,
I have this jsp client that consumes a webservice. The problem with the client
I have this strange behavior in my JSP page: I have two Integer variables

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.