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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:39:55+00:00 2026-06-06T19:39:55+00:00

I am using Tomcat7 on Windows Server 2008. I have the following two lines

  • 0

I am using Tomcat7 on Windows Server 2008.

I have the following two lines in my JSP page

<apptags:SQLIteratorTag query="<%=myQuery%>">
</apptags:SQLIteratorTag>

If myQuery returns at least one row, then my JSP page behaves normally.
If myQuery returns no rows, then my JSP page copies some text from the page (e.g. the contents of a combobox) and duplicates it!

My thoughts are as follows: Since the combobox that it copies from is populated by a query, it seems that in the absence of a query returning results, the page seems to grab the results of a different query.

Has anyone got any ideas how to solve this?
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-06-06T19:39:56+00:00Added an answer on June 6, 2026 at 7:39 pm

    Scriptlets <%...%> in a JSP body are oftenly messy. They can be fully avoided by using JSTL @taglib with EL ${...}, which is the clean and highly recommended way to iterate your query results in JSP.

    Download jstl-api.jar and jstl-impl.jar, put them in your lib folder and add to the top of the page:

    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
    

    For the query part, leave all the processing to a Java class, storing the query results in a variable myList of type List and sending it (get/post forward) to your page, which should only show the values and nothing else:

    <c:forEach items="${myList}" var="product" varStatus="status">
        Product number ${status.count}: ${product}<br />
    </c:forEach>
    

    This should be enough to avoid unexpected behaviours in your page. It’ll simply do nothing if there’s no rows. But if you still wanna check that, you wouldn’t have to do the query again, since its results are already inside myList:

    <c:if test="${fn:length(myList) != 0}">
        <c:forEach items="${myList}" var="product" varStatus="status">
            Product number ${status.count}: ${product}<br />
        </c:forEach>
    </c:if>
    

    Or use ${noCompanySelected} instead of ${fn:length(myList) != 0}, if that’s really your condition.

    …Other things you may want to verify:

    Your myQuery is being reused by something else, somewhere else in your application… or recursively twice by the same page if you created myQuery in the session instead of request.

    Also, if your taglib apptags was made by yourself, another possibility is that it’s manipulating tags it shouldn’t.

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

Sidebar

Related Questions

My application runs SQL Server 2008 on Windows Server 2008 using Tomcat. I am
The following code is for authenticating to a windows AD server using Java+Kerberos and
The system is using Windows Server 2008 R2 SP1, Tomcat 5.5.28, and Java SE
I recently migrated my JSF app(using primefaces) from glassfish 3.1 to tomcat7 server. Previously
i am using tomcat server and i have added a rhino engine to able
We're using Windows 2008 and we are thinking of switching application servers from Adobe
Scenario: Apache Tomcat 6.0 is started as a service on Windows Server 2008 R2
I have a script which detects OS using Catalina.bat for windows and Catalina.sh for
I have a web project using jsf2 implementing a gaming web site on tomcat7.
Windows Server 2008 / IIS 7... I am trying to setup and CI environment

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.