JSP:Dynamic Linking

JSP:Dynamic Linking

View Answers

March 14, 2009 at 12:11 AM

Hi friend,

Code to help in solving the problem :

"view1.jsp"

<%@page import="java.sql.*"%>
<%

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='view2.jsp?id=<%=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>

Id having an anchor link .You click on it and display the full details on the next page "view2.jsp"

"view2.jsp"

<%@page import="java.sql.*"%>
<%

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";
int id=0;
String roll_no="";
String lastname="";

if(request.getParameter("id")!=null)
{
id = Integer.parseInt(request.getParameter("id").toString());

}
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,username,userPassword);
Statement st = conn.createStatement();
String strQuery = "select * from rollno where id="+id;
ResultSet rs = st.executeQuery(strQuery);
int count=0;
if(rs.next()){
roll_no=rs.getString("roll_no");
lastname=rs.getString("lastname");
}
%> <br><br><br>
<table width="200px" align="center" style="border:1px solid #000000;" >
<tr><td width="50px"></td><td width="10px"></td><td></td></tr>
<tr style="background-color:efefef;">
<tr><td><b>Id</b></td><td align="center"><b>:</b></td><td><%=id%></tr>
<tr><td><b>Roll_no</b></td><td align="center"><b>:</b></td><td><%=roll_no%></tr>
<tr><td><b>LastName</b></td><td align="center"><b>:</b></td><td><%=lastname%></tr>

</table>
<br><br>
<table width="100px" align="center" border=0><tr>
<% conn.close();
} catch (Exception e) {
e.printStackTrace();
}
%>

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

Thanks









Related Tutorials/Questions & Answers:
ModuleNotFoundError: No module named 'linking'
ModuleNotFoundError: No module named 'linking'  Hi, My Python... 'linking' How to remove the ModuleNotFoundError: No module named 'linking... to install padas library. You can install linking python with following command
ModuleNotFoundError: No module named 'linking'
ModuleNotFoundError: No module named 'linking'  Hi, My Python... 'linking' How to remove the ModuleNotFoundError: No module named 'linking... to install padas library. You can install linking python with following command
Advertisements
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
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
html text linking
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
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
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
Why the Google Penguin update is good for SEO
of Google Penguin 2.0 SEO are being forced to forfeit unrelated linking patterns and unrelated back linking that were once the driving force for traffic
Why are Ranking affected by Penguin 2.0 Update
paid linking. 2.3% English searches were affected but bigger was the affect... link building techniques involved paid linking, you need to tell your SEO
Eclipse Wiki Editor Plugin
documentation tool linking documentation to eclipse resources, web sites, bug
How to Protect against the Penguin Update
guest posting and social networking sites to generate genuine linking. Stop
SEO analyst
and development  Online promotion, inbound linking
Recovering Blog From Penguin 2.0 Update Penalty
Linking: A low quality link profile is most commonly caught by penguin penalty..., linking websites with low domain authority and embedding irrelevant links in your blog. Moreover, to avoid such linking's first analyse your backlinking
What are Key Features to overcome Penguin Update?
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
make a picture a link
make a picture a link  hello, What is the way to make a picture a link?   hii,ADS_TO_REPLACE_1 This is the tab for image linking <A HREF="http://www.roseindia.net"><IMG SRC="image.gif"></A>
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? ThanksADS_TO_REPLACE_1   Hello, You must be getting the linking errors
in need od source code - Development process
a source code for creating the front end, and for database, and linking from front end
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
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
How to Recover from Penguin 2.0 Update Penalty?
keyword and buy 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
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. 
Lasso Studio for Eclipse
within Lasso including formatting phone numbers, stripping white space, auto-linking
Flex 4 Features
for Vector to restrict to a single typeADS_TO_REPLACE_5 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
Google Penguin Update 2013
understood that websites carrying out black-hat SEO, automated back linking, using... content and no fake back-linking. Some people have misunderstood the meaning
Penguin 2.0 update: What likely changed and How to Recover
your websites.ADS_TO_REPLACE_1 SEO who were involved in spam linking (it covers a wide range of spamming) like paid linking, similar anchor text
Google Penguin Algorithm update issues and How to Recover
in such paid linking have seen a major dive in their ranking as Penguin 2.0... this category. Stop spam linking in comment section of forums and discussions. Stop
ZF Page Redirect
;;ADS_TO_REPLACE_5 $this->view->headTitle("Linking Page"
java - Java Beginners
linking and embedding), applets are becoming more prevalent. A well-designed
XML Related Technologies: An overview
, paper or other media. XLink (XML Linking Language) is a language for creating
How to link a excel file with a application software using java swing
); frame.setTitle("Select File for Linking
How to link a excel file with a application software using java swing
); frame.setTitle("Select File for Linking
How to link an excel file with the application software using java swing
_ON_CLOSE); frame.setTitle("Select File for Linking
PHP
except the Report linking to the next Menu. Choose your own columns and data type
Web Page
linking to the next Menu. Choose your own columns and data type for the database
Submit button to MySQL database?
Submit button to MySQL database?  Need help linking html code to mysql database <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here<
Submit button to MySQL database?
Submit button to MySQL database?  Need help linking html code to mysql database <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here<
JSF Life Cycle
-level events like form submission, linking to another page are handled
What are Google Penguin Update Issues?
the rest.ADS_TO_REPLACE_1 Then there is paid linking, which the Penguin 2.0
Google Ranking Update for Spammy Queries
queries and targeted paid linking, duplicate content and keyword stuffing
PHP User Authentication Login and password check Tutorial
to lessen any confusion. And that's it. You can access it by start to linking

Ads