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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:16:27+00:00 2026-05-27T01:16:27+00:00

I have a search function that returns an arraylist of objects to my form.

  • 0

I have a search function that returns an arraylist of objects to my form. I am iterating through the list using JSTL’s foreach tags.

<c:forEach items="${searchResults}" var="contact" varStatus="loop">
<div style="padding: 5px;">
${contact.firstName} ${contact.lastName}
<br>
${contact.primaryPhone}
<br>

//Is this the proper way to set up the url?
<a href="Contacts?search=${param.search}&id=${loop.index}">View Contact</a>

</div>
<br>
</c:forEach>

When the user clicks the link inside each row, the row index is passed to the querystring and at this point I would like to show a div that contains additional information about the user.

I have a javascript function that I use to display the div and center it on the screen bla bla bla, but my question is how do I refresh the page with the index loaded into the querystring and then fire my javascript function?

I considered using:

<c:if test="${not empty param.id}">
//Check if id in querystring is available and if so, display popup
</c:if>

To check if there was an index available in the querystring, but I don’t think there is a way to fire my function from within a JSTL tag.

Should I be doing something on the server side when I request back to the servlet rather than trying to handle this on the client side? I just figure its a waste to requery my database and set another request parameter, when I already have the information I need stored in a parameter than I am using to display my list anyways.

  • 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-27T01:16:28+00:00Added an answer on May 27, 2026 at 1:16 am

    The solution I eventually came up with is to check for my id parameter in the querystring each time the page loads (with javascript)

    function init(){
    console.log("Contacts page loaded.");
    
    //Loads popup if 'id' is present in the querystring.
    if(getQuerystring('id', 'null') !== 'null') {
        showCenteredDiv('popup');
    }
    };
    

    The function I use to check the querystring is:

    //Search querystring for a specific parameter. Second arg is the value to display if its not found.
    function getQuerystring(key, default_)
    {
      if (default_==null) default_="";
    
      key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
      var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
      var qs = regex.exec(window.location.href);
    
      if(qs == null) {
        return default_;
      } else {
        return qs[1];
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that uses Pattern#compile and a Matcher to search a list
I have a sql function that accepts keywords and returns a full text search
I have a search function that returns the email for a user when I
I have a search function that executes a stored procedure and returns results. If
I have a controller that returns a list of custom linq-to-sql model objects in
I have a problem using the Java search function in Eclipse on a particular
I have a function that takes a floating point number and returns a floating
I have an Ajax request that returns search results, and I am dynamically creating
Hi I have a simple ajax search that returns the results in a table.
I have the following code that returns rows from a database when a form

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.