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



Home Answers Viewqa Development-process jsp with database..
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


gautam jagnani
jsp with database..
2 Answer(s)      4 years and 7 months ago
Posted in : Development process


Hello i need code for.....

I have a car brandimage on my front page.on clicking it it is directed to a model.jsp page.....what i need is on clicking a particular brand only the corresponding models of that brand should be retrieved from database.i have created a table in database which have brand,model,price as attributes.

thanks.

Advertisement
View Answers

May 28, 2010 at 4:36 PM


Hi Friend,

Try the following code:

1)index.jsp:

<html>
<form action="model.jsp">
<center><input type="image" src="car.jpg" ></center>
</form>
</html>

2)model.jsp:

<script language="javascript" type="text/javascript">
function call(brand){
window.open('info.jsp?brand='+brand,'mywindow','width=400, height=250,toolbar=no,resizable=yes,menubar=yes');
}
</script>
<h1>Car Brands</h1>

<a href ="javascript:call('Tata')">Tata </a><br><br>
<a href ="javascript:call('Ford')">Ford </a><br><br>
<a href ="javascript:call('Maruti')">Maruti </a><br><br>
<a href ="javascript:call('Honda')">Honda </a><br><br>
<a href ="javascript:call('Toyota')">Toyota </a><br><br>
<a href ="javascript:call('Chevrolet')">Chevrolet </a><br><br>

3)info.jsp:

<%@page import="java.sql.*"%>
<%
String brand=request.getParameter("brand");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root";, "root");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select * from car where brand='"+brand+"'");
if(brand!=null){
%>
<center><h1><%=brand%></h1></center>
<center><table border="1" width="80%" height="50%">
<tr><th>Brand</th><th>Model</th><th>Price</th></tr>
<%
while(rs.next()){
%>
<tr><td><%=rs.getString(2)%></td><td><%=rs.getString(3)%></td><td><%=
rs.getString(4)%></td></tr>
<%
}

%>
</table></center>
<%
}
%>

Thanks


May 28, 2010 at 4:37 PM


For the above code, create database table named 'car':

CREATE TABLE `car` (
`id` bigint(255) NOT NULL auto_increment,
`brand` varchar(255) default NULL,
`model` varchar(255) default NULL,
`price` double default NULL,
PRIMARY KEY (`id`)
)

Thanks


Related Tutorials/Questions & Answers:
jsp database
jsp database   I want to retrive value in my jsp page but i dont want show my database query in my jsp page. is there any other method to show value in my jsp page using java class
connect to the database from JSP
connect to the database from JSP  How do you connect to the database from JSP?   A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets
Advertisements
connec to database - JSP-Servlet
connec to database  Need code to connect the application to database. I have developed the application JSP and Servlet
upload to database - JSP-Servlet
to upload a pdf file into database(sqlserver2000) using jsp. In roseindia some examples... into database whenever i want that uploaded pdf file i have to retrieve it from database please help me friends thanks in advance it is very urgent
connection with database - JSP-Servlet
and the connection with the database using jsp code, I get exceptions that I have... with java code. Is there any other way to establish a connection with database in jsp... with the database by writing the program in java. Following is the code: import
JSP Database Example
This example shows you how to develop JSP that connects to the database and retrieves the data from database. The retrieved data is displayed on the browser. Read Example JSP Database Example Thanks
jsp with database.. - Development process
jsp with database..  Hello i need code for..... I have a car... of that brand should be retrieved from database.i have created a table in database... Thanks  For the above code, create database table named
jsp with database oracle
jsp with database oracle  hai i am doing one program in jsp i want to check the jsp life cycle methods so wrote one program, in which i write jspInit() method and jspDestroy() methods. but i am getting error i crate a table
JSP and Database access
JSP and Database access  Hi, Please help me with the following program. I am not able to update all the pa column values in my database. csea.jsp: <html> <body> <%@page import="java.sql.*"%> <form method
database through jsp
database through jsp  sir actually i want to retrieve the data from database dynamically.because i dont know how many records are there in the database? thanks   Here is an example of jsp which retrieves data from
line chart from database in jsp
line chart from database in jsp  how can i create line chart from database in jsp code
database - JSP-Servlet
database  how to downloaad a file(doc) from database and store in any local system by using servlet
jsp and database - Java Beginners
jsp and database  I m making a project for an agentto store record using jsp and oracle database.I want that when the premium of any policy holder is half yearly or quarterly then when the person submit premium in a month lets
Update Database from jsp
Update Database from jsp   I want to update my oracle database column from a text box ,so whenever I input some text value in the text box and click UPDATE button the database field should be updated . I have a drop down menu
Jsp Code to store date in database - JSP-Servlet
Jsp Code to store date in database   Hi, Can u give me jsp code to store current date in to database. Thanks Prakash
Backup MySQL Database - JSP-Servlet
Backup MySQL Database  Database Sir I have been reading Rose's india tutorial "Using MySQL Database with JSP/Servlet". In the Tutorial you have shown an example of backing up the database. When I tried to backup database
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
oracle database backup using jsp
oracle database backup using jsp   I want to take the backup of oracle database.I want to write the code in jsp ,so that when the page is loaded a backup of the database is stored in one of my local drives.Is it possible to do
To insert attachment file in database in JSP.
To insert attachment file in database in JSP.  I am doing project in JSP. How to insert attachment file in mysql database? Please suggest some solution. Your inputs is valuable to me.   Hi Friend, Visit Here Thanks
display date to jsp from database
display date to jsp from database   display date to jsp from database to calender if the start date and end date is available than calender date... not available in database field than show in green color and clickable. NOTE :- Date
Connecting to Database from a hyperlink in JSP - JSP-Servlet
Connecting to Database from a hyperlink in JSP  How can I connect to database by clicking on a hyperlink in a JSP Page.Can you please give me sample... which is connect to database using jdbc database
Problem in Jsp and database - Development process
Problem in Jsp and database  Hi, How can I reterive values from database and display them in teextboxes so that when the user select the UPDATE... to the database itself . Thanks in advance.  Hi Friend, You can use
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
Draw graph using jsp without database connection
Draw graph using jsp without database connection  Draw graph using jsp code without database connection
database connectivity using jsp code
database connectivity using jsp code  i have two tables employee...),'bbbb','bbbb'); so this syntax is possible to use in jsp code based on employee id ename and designation are displayed how it is possible in jsp employee
Database connectivity with jsp code - JSP-Servlet
Database connectivity with jsp code  I have written a program in java having connectivity with online_exam. Its working properly. Connection has been... is there with jsp code.Its giving the exceptions I have posted u before. I dont know
connecting to a database dynamically - JSP-Servlet
connecting to a database dynamically   abc.html... java.lang.NullPointerException org.apache.jsp.abc_jsp._jspService(abc_jsp.java:72... with database dynamically. Plz debug the code and explain the reasons for the exception
jsp- database dependent dropdown list
jsp- database dependent dropdown list   i want 2 dropdown list 1- CLASS 2-SECTION both are should come from database. and if i select a class... respective to that class from database. please help by providing the code in jsp
data are not display in JSP from database - JSP-Servlet
data are not display in JSP from database   i want to finding some data through a SQL query from SQL server database to a JSP page based on some... of this jsp page. like.. School Result and three request parameters 'class', 'from
Advertisements
 

 

 

DMCA.com