Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet JSP: Dynamic Linking
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Bhushan
JSP: Dynamic Linking
2 Answer(s)      5 years and 7 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

March 13, 2009 at 2:44 AM


Hi Friend,

Here is the code which will help you in solving your problem. You can use <a href ="<%rs.getInt("id"%>)"><%rs.getInt("id"%></a> method inside your result set loop to provide them a dynamic link.

JSP Code is as follows :

<%@ page language="java" import="java.sql.*;"%>
<html>
<head>
<style>
A:hover {
text-decoration: none;
font-family:arial;
font-size:12px;
color: #000000;
BORDER: none;

}
A {

text-decoration: underline;
font-family:arial;
font-size:12px;
color: #000000;
BORDER: none;

}
</style>

</head>
<body>

<%

Connection conn = null;
String url = "jdbc:mysql://192.168.10.112:3306/";;
String dbName = "student";
String driver = "com.mysql.jdbc.Driver";
String username = "root";
String userPassword = "root";
String color = "#F9EBB3";

try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,username,userPassword);
Statement st = conn.createStatement();
String strQuery = "select * from rollno";
ResultSet rs = st.executeQuery(strQuery);
int count=0;
%> <br><br><br>
<table width="700px" align="center" style="border:1px solid #000000;" >
<tr>
<td colspan=8 align="center" style="background-color:ffeeff"><b>All Students</b></td>
</tr>
<tr style="background-color:efefef;">
<td><b>Id</b></td>
<td><b>Roll_no</b></td>
<td><b>LastName</b></td>

</tr>
<%
while(rs.next()){
if((count%2)==0){
color = "#eeffee";
}else{
color = "#F9EBB3";
}
count++;

%> <tr style="background-color:<%=color%>;">
<td><a href='<%=rs.getInt("id")%>'><%=rs.getInt("id")%></a></td>
<td><%=rs.getString("roll_no")%></td>
<td><%=rs.getString("lastname")%></td>
</tr>
<%
}
%>
</table>
<br><br>
<table width="100px" align="center" border=0><tr>
<% conn.close();
} catch (Exception e) {
e.printStackTrace();
}
%>

</tr>
</table>
</body>
</html>

Thanks & Regards
RoseIndia Team


March 13, 2009 at 11:54 AM


Thank you for the answer.
but how can i display all the details of that id on next page.
Suppose i click on link for id 50, i should get rest details of id 50 on next page...
Please reply soon


Related Tutorials/Questions & Answers:
linking of pages in java
linking of pages in java  i made a login form accountno: password: submit /*here a "register" */ after clicking register i need to open... for login and other for register pls rply   Java linking two pages
Linking JMenu Item with a JPane in Netbeans
Linking JMenu Item with a JPane in Netbeans  How do you link a Jpane window to a JMenu Item in Java Netbeans
Advertisements
LINKING PAGES OF PROJECT ON BANKING MANAGEMENT
LINKING PAGES OF PROJECT ON BANKING MANAGEMENT  SIR. pls i want to know how to link pages such that by clicking a button different page gets open on which we can make addition or we can edit?? i m making project on Banking ..pls
Linking an Excel File with the Application tool
Linking an Excel File with the Application tool  I have to link an excel file with a application software which I am developing.I have this code...); frame.setTitle("Select File for Linking
linking php page to other php pages
linking php page to other php pages  How to link the PHP Page to other PHP page
Linking excel file with a application tool using swing
Linking excel file with a application tool using swing  I have to link an excel file with my application software using java swing.As soon as i... for survey.After linking the tool must be able to take those questions and generate
problem in linking the html page using servlets
problem in linking the html page using servlets  i want to create a login page using html & servlets and as soon as i click the login button it should open my home page. and i have saved username and password in a database
linking tree heading in javasript into a Jsp file and then jsp to struts action form
linking tree heading in javasript into a Jsp file and then jsp to struts action form  i have a tree that consists of 3 options say for example 1) aaa 2) bbb c) ccc when i click either one of them it should go
JSP:Dynamic Linking - JSP-Servlet
JSP:Dynamic Linking  Hi This is extension to my previous question: " I am fetching data as a search result from database and displaying it in a table(id and name)using while(rs.next()){...}.I want to provide hyper link
JSP: Dynamic Linking - JSP-Servlet
JSP: Dynamic Linking  Hi I am fetching data as a search result from database and displaying it in a table(id and name)using while(rs.next()){...}.I... inside your result set loop to provide them a dynamic link. JSP Code
linking jsp with database using classes and methods and then access them all in to my jsp page - JSP-Servlet
linking jsp with database using classes and methods and then access them all in to my jsp page  how to connect jsp page with mysql using classes and methods so that i can use the reusability character of java.  just
Why are Ranking affected by Penguin 2.0 Update
paid linking. 2.3% English searches were affected but bigger was the affect... techniques involved paid linking, you need to tell your SEO to stop them
Why the Google Penguin update is good for SEO
2.0 SEO are being forced to forfeit unrelated linking patterns and unrelated back linking that were once the driving force for traffic and ranking
Eclipse Wiki Editor Plugin
documentation tool linking documentation to eclipse resources, web sites, bug
How to Protect against the Penguin Update
and social networking sites to generate genuine linking. Stop Spamming, duplicate
SEO analyst
and development  Online promotion, inbound linking,  Publishing links
Recovering Blog From Penguin 2.0 Update Penalty
that could help you recover your blog from Penguin 2.0 penalty: Linking: A low... profile can be inferred to posting spam comments on different blogs, linking.... Moreover, to avoid such linking's first analyse your backlinking using various tools
make a picture a link
make a picture a link  hello, What is the way to make a picture a link?   hii, This is the tab for image linking <A HREF="http://www.roseindia.net"><IMG SRC="image.gif"></A>
java - Struts
java  Dear Sir/Madam, I am not getting what is the purpose of .property file and how form bean,Jsp and property file are linking with each other, and how the control flows with in these files(form bean, jsp, property
Foreign key in mysql
Foreign key in mysql  Hi I am creating a website and linking it to a database using php and mysql. I need to create the databases in phpmyadmin and have decided on the structure of the tables in the database. However, as expected
FastTrack
and planning Customizable Work Item types Linking of Work Items with each other Linking of Work Items with other artifacts in workspace Linking repository revisions to Work Items (traceability) Searching Work Items
in need od source code - Development process
a source code for creating the front end, and for database, and linking from front end
libxml2.2.dylib iphone
libxml2.2.dylib iphone  Hi, I added the libxml2.2.dylib in iPhone application, still its not able to compile the XML processing code. What to do? Thanks   Hello, You must be getting the linking errors. You should
How to Recover from Penguin 2.0 Update Penalty?
an anchor text of it from a website. This is paid linking. Penguin 2.0 has made it clear that they will specifically target such type of linking. Also unrelated linking (like if you have a travel website and you are taking a link from paint
Lasso Studio for Eclipse
within Lasso including formatting phone numbers, stripping white space, auto-linking
File download security.
File Download Security  This script prevents the file to be linking to other file as this script force the file to be downloaded well before the beginning of downloads. This script is very crucial for highly secured documents. 
Flex 4 Features
. Support for Vector to restrict to a single type 12. RSL linking by default to reduce the application size rather than static linking 13. StyleManager
Writing Great Articles is Difficult
and linking your site or blog from some other newsletter or site. Articles help... requirements. Copying articles from the internet and linking them to your site... offered by you and linking them back to your webpage, you can reap monetary benefits
XML Interviews Question page9
affect my document links? A: The linking abilities of XML systems... with them. Existing href-style links will remain usable, but the new linking... XLink. The XML Linking Specification (XLink) and the XML Extended Pointer
 

 

 

DMCA.com