Make the URL retrived from database a href link to navigate to that page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajay13785
    New Member
    • Oct 2013
    • 10

    Make the URL retrived from database a href link to navigate to that page

    I have retrieved the url link from the database in a text box .Now I want to make the retrived url to be a href link . How can I achieve it.

    My code is below:

    Code:
    <%@page language="java"%>
    <%@page import="java.sql.*"%>
    <table border="1">
    <%
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    Connection con = DriverManager.getConnection(
    	    "jdbc:oracle:thin:@10.1.2.51:1521:ECPROD","SMUSER","password");
    String query = "select * from TEST_LINKS where ID='224'";
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery(query);
    if(rs.next()){
    %>
    <tr>
    <tr><td>URL</td><td><input type="text" name="name" value="<%=rs.getString("URL")%>"></td></tr>
                  
    
    <%
    }
    }
    catch(Exception e){}
    %>
    </table>
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    1.) Do not write database connection code in a JSP. Put it in a normal Java class and test that it works before writing your JSP. Then call that code from a servlet.

    2.) Don't ever do
    Code:
    catch(Exception e){}
    . That just hides any exceptions that could be happening.

    Comment

    • itsraghz
      New Member
      • Mar 2007
      • 124

      #3
      In addition to the suggestions and tips given by r035198x, to answer your actual question, you can add the "<a href="">LinkFro mDatabase</a>" to your content retrieved from the database.

      Tip: You should actually escape the double quotes using \.

      Comment

      Working...