problem in jsp programming

problem in jsp programming

View Answers

March 21, 2009 at 2:38 AM

Hi friend,


Code to help in solving the problem :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">;

<%@ page import="java.sql.*,java.text.*,java.util.*" %>
<%@ page import="java.io.*" %>

<html>
<head>
<title>Connection with mysql database</title>
</head>
<body>
<h1>Connection status </h1>
<table>
<tr><td>Item Name</td><td>Company</td><td>Address</td></tr>
<%
try {

Date date = new Date();

// Some examples
Format formatter = new SimpleDateFormat("yyyy-MM-dd");
String currentdate = formatter.format(date);

/* Create string of connection url within specified format with machine name,
port number and database name. Here machine name id localhost and
database name is usermaster. */
String connectionURL = "jdbc:mysql://localhost:3306/usermaster";;

// declare a connection by using Connection interface
Connection connection = null;

// Load JBBC driver "com.mysql.jdbc.Driver"
Class.forName("com.mysql.jdbc.Driver").newInstance();

/* Create a connection by using getConnection() method that takes parameters of
string type connection url, user name and password to connect to database. */
connection = DriverManager.getConnection(connectionURL, "root", "root");
Statement stmt = connection.createStatement();

String query = "select * from table where itemdate='"+currentdate+"'";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
%>
<tr><td><%=rs.getString("item_name")%></td><td><%=rs.getString("company")%></td><td><%=rs.getString("address")%></td></tr>
<%
}

}
catch(Exception ex){
%>
</font>
<font size="+3" color="red"></b>
<%
out.println("Unable to connect to database.");
}
%>
</table>
</font>
</body>
</html>

Thanks









Related Tutorials/Questions & Answers:
problem in programming - JSP-Servlet
problem in programming  Hi! I am new with jsp. I am facing a problem in programming to calculate the time interval between login time and logout time of user
problem in jsp programming - JSP-Servlet
problem in jsp programming  Write a JSP program which displays a webpage containing arrival of new items within a particular month in the different... in solving the problem : Connection with mysql database
Advertisements
programming problem
programming problem   Kingdom of Maplewood is a beautiful country comprising of a lot of small islands of different areas. All the islands are in a straight row. King Rosewood is getting old and has decided to divide the islands
java programming problem - JDBC
java programming problem  Hi, Request you to provide the source code in Java for the following programming problem : upload .csv file data into oracle database. please send the solution to [email protected]
Programming with JSP
Programming with JSP  Write a program using jsp that accepts a course code as input and displays the course title the program to which it belongs
Programming with JSP
Programming with JSP  Who will post me the answer
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
java programming problem - JDBC
java programming problem  Hi, Request you to provide a solution ( analysis & design & unit test plan & code & test criteria ) to the following problem to the following mail id : Problem : upload excel file data into oracle
Jsp problem
Jsp problem  Hello friends.I want to share my jsp problem.I want to show all of my database(mysql) tables except two(user,manufacturer) in a jsp page.plssss help me
jsp problem
jsp problem  problem:::::::: On JSP form ,when i insert data in text field........at that time action is perform and data is retriev from data base and get assign to other field on that form........ when data is assign to other
jsp problem
jsp problem  Hello Friends, I want to show one page for 5 seconds and after that i want to redirect the page to another URL
Programming problem - Java Beginners
Programming problem  Good afternoon Ma'am/Sir, Can you help me... it difficult to learn java programming? Based on my survey it seems that java programming is the hardest part of their studies.. I also want to know
jsp problem
jsp problem  Hi every one plz give me answer for below question ASAP I created one JSP(used pre defined javascript in jsp to get rtf format in browser) which creats RTF Format in browser to enter data. MY question is after i
jsp programming
convert a pdf file int svg file using pdftron and dishplay in jsp at run time JSP  I am also in trouble is that I want to convert a pdf file int svg file using pdftron and dishplay in jsp at run time. plz guide me n thanks
jsp programming
converting a pdf file to png format using pdftron JSP programming  Hello, I am trouble in converting a pdf file to png format using pdftron. plz guide me, n thanks in advance
Programming - JSP-Servlet
Programming jsp servlet   Couple of examples that can help to start programming jsp servlet
JSP Problem - JSP-Servlet
JSP Problem  Hi, I have problem,this is my senario I have one jsp,this jsp having the 3 fields.let me take 3fields userName,emailAddress... for more information, http://www.roseindia.net/jsp Thanks
programming problem - Java Beginners
programming problem  i am using FileDialog to select an image and displaying it on a canvas using getDirectory() and getFile(). now i want to use the path obtained from getDirectory() and getFile()to obtain same selected image
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database through jsp. but i cann't set size of image when it was display so what should... working but my problem is size of image. so can u just help?? code
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database through jsp. but i cann't set size of image when it was display so what should... working but my problem is size of image. so can u just help?? code
java programming problem - Java Beginners
java programming problem   Given a deck of ncards unique cards.Cut the deck iCut cards from the top portion of the deck followed by the bottom card... etc. Alternating the remaining cards go on top. The problem is to find
jsp programming - JSP-Servlet
jsp programming  How to retrieve the invoices from the tally to jsp
Programming in JDBC and JSP - JSP-Servlet
Programming in JDBC and JSP  Write a program using JDBC and JSP to display the names and addresses of all those MCA students at your study centre... Semester.   Hi friend, Code to help in solving the problem
jsp problem - JSP-Servlet
jsp problem  hi, i am working on a project of developing a shopping cart for online book store.can it be done using jsp?if yes, can u please help me doing so?  Hi Friend, Please visit the following link: http
java programming problem - Java Beginners
java programming problem   num=(a/b)*(c/d) In the problem, 'num' is given . "0<2" we have to find out the values of a,b,c,d upto five places of decimal. there can be many combinations of a,b,c,d . the solution space
Java programming problem - Java Beginners
Java programming problem  could anyone help me to solve this problem... Implement a superclass Person. Make two classes, Student and Instructor that inherit from Person. A Person has name, year of birth and day. Student has
jsp code problem - JSP-Servlet
jsp code problem  Hi, I have employee details form in jsp. After... have a problem with open the next form. plz, help me. thanks,  Hi.... http://www.roseindia.net/jsp/ Thanks
Session Problem in JSP - JSP-Servlet
Session Problem in JSP  I have developed a online feedback form in JSP platform. I have created normal session in JSP page. It is running in my... normally from Remote machine by only writing JSP code.  Hi friend
java programming problem - Java Beginners
java programming problem  we are given a number ,num. ( 0<2 ) we have to represent the number(num) in the form of a,b,c,d such that: num=(a/b)*(c/d) for eg. let num=2, then a=1.5 b=0.75 c=0.4 d=0.4
java programming problem - Java Beginners
java programming problem  Hello..could you please tell me how can I count the occurrence of EACH alphabet in a string..? Thanks  Hi Ruby I am sending some link where you can find solution of your prblem
Java Programming Problem - Java Beginners
Java Programming Problem  Q. How write a program that asks the user's name, and then greets the user by name. Before outputting the user's name, convert it to upper case letters? For example, if the user's name is Fred
jsp usebean problem - Struts
popupwindow jsp below code run.. ...here iam getting the problem..in the below...jsp usebean problem   --Select... jsp
jsp reload current page problem
jsp reload current page problem  Hi, i am facing problem while reloading the JSP page
jsp reload current page problem
jsp reload current page problem  Hi, i am facing problem while reloading the JSP page
Programming Error - JSP-Servlet
Programming Error  Image: I want that when user clicks on browse button then a folder of images should get open and when user clicks one image... is access). Then how to do this in jsp?? Please Reply me?? Please do Reply
Programming Error - JSP-Servlet
Programming Error   Payment Advertisement Management System Payment Premium Position FrontPage BackPage Other Premium Pages... statement in jsp i want to calculate the price of placing ad according to user
Programming Error - JSP-Servlet
Programming Error  Image: Browse When user clicks on Browse Button then a folder of images should get open and when user clicks one of them...("http://localhost:8080/examples/jsp/modify.jsp?filename="+filename
Programming Error - JSP-Servlet
Programming Error   function Draft() { if(document.form.Count.value==""||document.form.Count.value==null) document.form.Count.value=0; else...; } Draft Your Ad here: No of words: There is some problem
logout problem?? - JSP-Servlet
logout problem??  sir, the logout code which u have send is not the proper solution coz,by using this code the browser get closed which shuold.../Logout.shtml http://www.roseindia.net/jsp/loginstatus.shtml Thanks
Programming Error - JSP-Servlet
Programming Error  How to validate login page using jsp where it checks for username whether it is empty or not or is it including number or not if it is the paste alert message.   Hi Friend, Try the following
jsp image problem - JSP-Servlet
jsp image problem  hi everyone, How to display multiple images from mysql database to jsp page. please help me
Servlet - JSP Programming - JSP-Servlet
Servlet - JSP Programming  Hi, I'm writing a jsp page as shown below. I have to buttons of type submit. Any time only one is selected(either add to cart or checkout). I'm programming in a servlet getting the input parameters
logout problem.. - JSP-Servlet
logout problem..  hi... first of all thanks for ur... but their is some problem with the the logout,i m not able to logout when... done in the code i have used session object in project's servlet and jsp
coding problem - JSP-Servlet
coding problem  dear sir i m very new to JSP sir i m getting problem in dynamically changing the option of combobox from database(ms acess) .and after that option being selected for that the record from the databse should
JSP code problem - JSP-Servlet
JSP code problem  Hi friends, I used the following code...: <% //to get the content type information from JSP... of: Please can somebody rectify this problem........  
Programming Error - JSP-Servlet
Programming Error   Place Ad Advertisement Management System Create Ad State: City: Main... is it possible in jsp. when user types some thing in draft ad textarea
Jsp Code Problem - JSP-Servlet
Jsp Code Problem  I use DocType in my Jsp Page. The Links are not functioned after Applying the DocType. Could you tell me any way to activate the link. Thank You.   Hi Friend, Please send your code. Thanks
JSP code problem - JSP-Servlet
JSP code problem  HI.. I have a DB2 stored procedure wich return a result set. I have made a report basing on this procedure using Crystal Reports. How to pass parameters to this procedure with java code in a JSP page

Ads