473,387 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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:

Expand|Select|Wrap|Line Numbers
  1. <%@page language="java"%>
  2. <%@page import="java.sql.*"%>
  3. <table border="1">
  4. <%
  5. try {
  6. Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
  7. Connection con = DriverManager.getConnection(
  8.         "jdbc:oracle:thin:@10.1.2.51:1521:ECPROD","SMUSER","password");
  9. String query = "select * from TEST_LINKS where ID='224'";
  10. Statement st = con.createStatement();
  11. ResultSet rs = st.executeQuery(query);
  12. if(rs.next()){
  13. %>
  14. <tr>
  15. <tr><td>URL</td><td><input type="text" name="name" value="<%=rs.getString("URL")%>"></td></tr>
  16.  
  17.  
  18. <%
  19. }
  20. }
  21. catch(Exception e){}
  22. %>
  23. </table>
Nov 6 '13 #1
2 1688
r035198x
13,262 8TB
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
Expand|Select|Wrap|Line Numbers
  1. catch(Exception e){}
. That just hides any exceptions that could be happening.
Nov 6 '13 #2
itsraghz
127 100+
In addition to the suggestions and tips given by r035198x, to answer your actual question, you can add the "<a href="">LinkFromDatabase</a>" to your content retrieved from the database.

Tip: You should actually escape the double quotes using \.
Nov 12 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Acorn Tutors | last post by:
Hi folks, what I would like to do is to store the name of a link, such as link1.php in a field, lets say the field is called Favoritelinks, in a database as a bit of text. Then, on a logged in...
3
by: Mark Pacey | last post by:
Hi, I have a web page that gets info from a mySQL database for various items, and slaps that info, along with pics onto the page. ( in a shopping site stylee) The pics have an href link, and I...
3
by: Ron James | last post by:
I would like to add a CSS link to every page on my site - "<LINK href="BLT.css" type="text/css" rel="stylesheet">". This links needs to go in the <HEAD> of my page. I was hoping that I could...
3
by: serge calderara | last post by:
Dear all, I have an application which display database result querry , store it in a dataset and bind a Datagrid control to it. I would like that the content of one particular column behaves...
1
by: serge calderara | last post by:
Dear all, I have a wrb application wich reads data from an SQL database and store them in a dataset. The dataset is then attached to a datagrid object I need to have a functionnality that when...
1
by: Mały Piotruœ | last post by:
Hello, (I am sorry for my English, it is not my native language.) I am new to JavaScript. Could you help me please with the following problem?: I need to make a href link on HTML page that leads...
12
by: Lance Wynn | last post by:
Hello all, Is there a way to use the ~/ path to link a CSS page? I thought maybe something like this would work, but no go: <link href="~/style.css" rel="stylesheet" type="text/css"/> Is this...
10
by: pt36 | last post by:
Hi I have a page with a form and a textbox. before to submit the form I want to chek if the inserted value in the textbox is already present in a database. So I need to pass the textbox value...
18
by: requeth | last post by:
I'm trying to do the following, but when I have the code in for hte HREF link I get a runtime error. How do I pass the link to the end user? <% Dim a as string Dim b as string a =...
3
by: debradager | last post by:
I would like to have a link on my home page that links to a services page and opens a toggle on that page about a particular service. The toggles by default will all be closed when only the page is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.