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

The Archive Base Latest Questions

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

In my JSP page I am fetching values from a sql statement in a

  • 0

In my JSP page I am fetching values from a sql statement in a ArrayList, which is getting created as table content. a set of values in this list would be a url. How can I convert this particular td element (the one with url) to be a hyperlink action item?

Here is the jsp code

<table border="1" id="tableView">
    <thead>
        <th></th><th>ID</th><th>Name</th><th>Description</th><th>Active</th><th>Release Date</th><th>Url</th>
    </thead>

    <tbody>
    <%
    if(max==0)
    {
        %><tr><td></td><td colspan="5" class="viewa"><% out.println("No Records found."); %></td><%
    }
    else
    {

        for(int i=0;i<result.size();i++)
        {
            %><tr><td><input class="tablechkbox" type="radio" name="prodAlertsRad"/></td><%

            List r=new ArrayList();
            r=(List)result.get(i);
            for(int j=0;j<r.size();j++)
            {
                %><td class="viewa"><%out.print(r.get(j));%></td><%
            }
            %></tr><%
        } 
    }
    %>
    </tbody>
</table>

You can test it here jsfiddle

  • 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:05:22+00:00Added an answer on June 6, 2026 at 7:05 pm

    You need to make change in this part of your code.

    for(int j=0;j<r.size();j++) 
    {
       %><td class="viewa"><%out.print(r.get(j));%></td><%             
    }
    

    to make your url work as hyperlink, you need to use anchor tag inside ur td. Also, it is important to know the exact index where your url lies in the list r. Since in your case, url is at the last index, we can modify the code this way-

    for(int j=0;j<r.size()-1;j++) //changed to size-1
    {
       %><td class="viewa"><%out.print(r.get(j));%></td><%             
    }
     %><td class="viewa"><a href="<%out.print(r.get(r.size()-1));%>"><%out.print(r.get(r.size()-1));%></a></td><%
    

    you might need to do little handling to avoid indexOutOfBoundException. I leave it for u to do that 🙂

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

Sidebar

Related Questions

I have a jsp page in which rows are created dynamically to a table
I have a JSP page which accepts SQL queries, performs them then returns the
I have a jsp page which shows the contents of a table. While the
This is my jsp page (which is a modal page to another jsp page
I have created a jsp page which run fine when executed in tomcat.But when
I have a jsp page, which imports another jsp. This import is wrapped into
There is a JSP page in which i have an ArrayList variable. I need
I created a static jsp page with an image whose src is set to
I am having a JSP page, where i am dynamically creating a Table data.
I have a JSP page, which accepts user strings in more than 23 languages.

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.