Home Answers Viewqa JDBC jsp fie execution in tomcat and using mysql

 
 


souumitra sikder
jsp fie execution in tomcat and using mysql
2 Answer(s)      3 years and 11 months ago
Posted in : JDBC

View Answers

July 7, 2009 at 12:23 PM


Hi Friend,

There is a problem in both JSP pages.
If you want to login,try the following code:

1)form.jsp:
<html>
<head>
<title>User Login</title>
<style type = "text/css">
body
{ font-family: tahoma, helvetica, arial, sans-serif; }
table, tr, td
{ font-size: .9em;
border: 3px groove;
padding: 5px;
background-color: #dddddd;
}
</style>
</head>
<body>
<form method = "post" action = "userLogin.jsp">
<p>Enter The User Name and Password to Log into our Student Database</p>
<table>
<tr>
<td>User name</td>
<td>
<input type = "text" name = "username" />
</td>
</tr>

<tr>
<td>Password</td>
<td>
<input type = "password" name = "password" />
</td>
</tr>
<tr>
<td colspan = "2">
<input type = "submit" value = "Log In" />
</td>
</tr>
</table>
</form>
</body>
</html>
2)userLogin.jsp:
<%@ page import = "java.sql.*" %>
<%@ page errorPage = "userDataviewErrorpage.jsp" %>
<%
String name1 = request.getParameter( "username" );
String name2 = request.getParameter( "password" );

Connection connection = null;
Statement statement = null;
Class.forName( "com.mysql.jdbc.Driver");

connection = DriverManager.getConnection( "jdbc:mysql://localhost:3306/test";, "root", "root" );
statement = connection.createStatement();

ResultSet resultSet = statement.executeQuery("SELECT * from login where username='"+name1+"' and password='"+name2+"'" );
if(resultSet.next()){
out.println("Welcome"+name1);
}else{
out.println("Invalid Username or Password");
}
%>

3)userDataviewErrorpage.jsp:
<%@ page isErrorPage = "true" %>
<html>
<head>
<title>Error!</title>

<style type = "text/css">
.bigRed
{font-size: 2em;
color: red;
font-weight: bold;
}
</style>
</head>
<p class = "bigRed">

The error message was: <br />
<%= exception.getMessage() %>
</p>
<p class = "bigRed">Please try again later</p>
</body>
</html>

The username and password that we used in the JDBC Connection are the MySql username and password.The code we have provided you checks whether the entered username and password is valid or not.

Thanks

July 7, 2009 at 12:29 PM


continue..........

And If you want to insert the new username and password,then try the following code:

<%@ page import = "java.sql.*" %>
<%@ page errorPage = "an.jsp" %>
<%
String name1 = request.getParameter( "username" );
String name2 = request.getParameter( "password" );

Connection connection = null;
Statement statement = null;
Class.forName( "com.mysql.jdbc.Driver");

connection = DriverManager.getConnection( "jdbc:mysql://localhost:3306/test";, "root", "root" );
statement = connection.createStatement();
int i=statement.executeUpdate("Insert into login(username,password) values('"+name1+"','"+name2+"')");

%>

For more information,please visit the following link:

http://www.roseindia.net/jsp/javascriptpagerefresh.shtml
http://www.roseindia.net/jsp/loginstatus.shtml

Hope that it will be helpful for you.
Thanks









Related Pages:
jsp fie execution in tomcat and using mysql - JDBC
jsp fie execution in tomcat and using mysql  I created 2 jsp files and kept them under a new directory in the web-apps subdirectory of Tomcat's...:THE LAST JSP PAGE IS COMING DIRECTLY ON EXECUTION IN TOMCAT
execution - JSP-Servlet
execution  hi, i am venkata ramesh, after complition of my servlet program, i start tomcat server(8080),using http://localhost:8080 ,but output... type 'admin' only, i am not given any password to tomcat server. how to execute
netbeans with mysql and tomcat
netbeans with mysql and tomcat  Hi. I have to run a JSP or JAVA file in netbeans with mysql database and tomcat server 7.0. But while the page loading itself it say error. ClassNotFoundException: com.mysql.jdbc.Driver. How
jsp using include & with mysql
jsp using include & with mysql  Sir, I am creating a login application using jsp & Mysql. The Codes are--- Html File...... <... and in tomcat lib. Please go through the following link: JSP Login Application
How to connect mysql with jsp
How to connect mysql with jsp  how to connect jsp with mysql while using apache tomcat
Expression Language execution in notepad
Expression Language execution in notepad  how to execute expression language in notepad for java i am using apache tomcat server4.0.
JSP tomcat hosting
JSP tomcat hosting  Hi, What is JSP tomcat hosting? Thanks  ... application on internet. But if you are using Tomcat to host the applications then the hosting environment is called as jsp tomcat hosting. There are many
execution of a jdbc program
execution of a jdbc program  how to execute a servlet program that..uses a jdbc driver (i.e. using mysql-connector -java )to connect to mysql in windows *PLS provid the execution steps in detail THANK YOU
Tomcat
Tomcat  to run one application in tomcat server which files we need.i think jsp,xml,html is sufficient
execution of java program
execution of java program  wat are the steps for the execution of the servlet-jdbc program on tomcat 5.5 server.. PlS provide..the execution steps... Foundation\Tomcat 5.5\common\lib\mysql-connector-java-3.0.17-ga-bin.jar
connection of jsp with mysql - JSP-Servlet
connection of jsp with mysql  can anybody tell me about connection of JSP with MYSQL? and also tell me which version is compatible with tomcat 4.1 i am using tomcat 4.1, MYSQL 5.0 but i have problem with connection
Tomcat
Tomcat  I am using UBUNTU and I want to install tomcat to run servlet programs
tomcat - JSP-Interview Questions
tomcat  how to run a program of jsp using tomcat server.please give... the tomcat, create a folder 'application' into C:\apache-tomcat-6.0.16... that create a jsp file 'hello.jsp'and put into the 'application' folder. To start
Tomcat
the project in tomcat where we can store the html and Jsp ad Java, XML files in the tomcat web apps folder. the following structure is correct or not Tomcat-web apps-my project(beside this one jsp file) Inside the my project WEB-INF
tomcat cache - JSP-Servlet
tomcat cache  hai friends i have a query that is i want to remove the cache memory from Tomcat server Automatically using jsp without deleting it manually from work folder because every time when i make any changes
tomcat - JSP-Servlet
servlet using tomcat 5 from the start..   Hi friend, Set... the environment variable by using the following steps. Go to Start->Control Panel... the values as Variable Name: CLASSPATH Variable Value: C:\Program Files\Java\Tomcat
hibernate execution - Hibernate
hibernate execution  how to create hibernate pojo classes in eclipse galileo ide. i want steps to this process. i want to retrieve date from mysql database using hibernate in eclipse galileo ide. any one plz send me steps
Download Tomcat
protocol for web server. Jasper : Jasper is called the JSP engine of Tomcat. JSP...Download Tomcat In this section we will discuss about downloading tomcat. This section will describe you about Apache Tomcat. This page will describe you
apache tomcat problem - JSP-Servlet
apache tomcat problem  hi, i am trying to run apache tomcat...\;"; i installed my apache tomcat in c: whats wrong with this  ...-tomcat-6.0.18\;" instead of using "CATALINA_HOME=C:\apache-tomcat-6.0.18\bin
JSP &MYSQL
JSP &MYSQL  Develop a web page for the telephone directory using jsp and mysql
Using MYSQL Database with JSP & Servlets.
Using MYSQL Database with JSP & Servlets.          MYSQL... acceres the MYSQL database. Here I am using MYSQL & tomcat server
Sysdeo Tomcat Launcher Plugin
This plugin does not contain Tomcat. (Download and install Tomcat before using... using this option : -clean - if Tomcat icons are not shown in toolbar : select... Tomcat using the default JRE checked in Eclipe preferences window
login page with mysql using jsp
login page with mysql using jsp  pls i need a sample of login page to check username and password in mysql database. thanks
servlet execution
servlet execution  i saved tomcat in path C:\Program Files\Java\Tomcat 6.0 there is file in tomcat lib folder as servlet-api(Executable jar file 84kb) how to set the servlet-api.jar in jcreator ide? please explain in detail
getting a problem in execution - Development process
the error as ERROR : (Access denied for user 'root'@'localhost' (using... the password given is TIGER it is taking as letters but in the MYSQL database it is taking
JSP-Mysql - JSP-Servlet
JSP-Mysql  Hello friends, Anyone send me the way how to store image in mysql database from a jsp page.  Hi friend, Code to insert image in mysql Using Jsp : For more information on JSP
Insert a row in 'Mysql' table using JSP Code
Insert a row in 'Mysql' table using JSP Code In this section, we will discuss about how to insert data in Mysql database using JSP code. Query...), Phone varchar(15), primary key(ID) ); NOTE : Download Mysql
servlet execution
servlet execution  there is servlet-api.jst in tomcat lib. How to set the servlet-api.jar in jcreator ide?   Hi, Visit Here Thanks
jsp and mysql
jsp and mysql  i have a form which contains dropdown list. i have to take the values to another jsp page and perform the calculation on the database which i have earlier using the values of the selected dropdown list
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using jsp
servlet execution
Files\Java\Tomcat 6.0\lib\servlet-api.jar* till i am getting following errors i follow all the instructions steps . C:\Program Files\Java\Tomcat 6.0\webapps... javax.servlet.*; ^ C:\Program Files\Java\Tomcat 6.0\webapps\examples\WEB-INF
Tomcat Books
, readers will find a coverage on database connectivity using Tomcat. ... more sophisticated Web applications. Tomcat version 5 supports the latest JSP..., and installation. A bonus discussion of Java Web development, using servlets and JSP
servlet execution
Files\Java\Tomcat 6.0\lib\servlet-api.jar* till i am getting following errors i follow all the instructions steps . C:\Program Files\Java\Tomcat 6.0\webapps... javax.servlet.*; ^ C:\Program Files\Java\Tomcat 6.0\webapps\examples\WEB-INF
Connection pool in Tomcat 6 - JDBC
Connection pool in Tomcat 6  Hi All, Any one please tell me how to implement connection pooling in Tomcat 6 and MySQL 5.0.1b. Thanks...://www.roseindia.net/jsp/jspfundamentals.shtml Hope that it will be helpful
servlet execution
servlet-api.jar inside the lib folder of apache tomcat. 1)create a servlet... apache tomcat and create a web application folder but it should having... your servlet. 7)Run Tomcat server by clicking the startup.bat file
servlet execution
servlet execution  there is servlet-api.jst in tomcat lib. How to set the servlet-api.jar in jcreator ide? please explain in detail.   Hi Friend, If you have created a project, then go to the Project>>
How to run a simple jsp page in tomcat???
How to run a simple jsp page in tomcat???  i am trying to run a simple jsp page in tomcat,i am having web.xml also in WEB-INF folder...\Tomcat 6.0\lib\servlet-api.jar using this ,i am able to run all servlet programs
MySQL Generate AlphaNumberic Id In JSP
numeric id using MySQL as database, tomcat 7 as a server for deploying the JSP...MySQL Generate AlphaNumberic Id In JSP In this section we will discus about how to generate id in specific format in MySQL and JSP. This example explains
MySQL allowMultiQueries JSP Example
MySQL allowMultiQueries JSP Example In this section we will discuss about how.... This example explains you all the steps for allowing multiple queries using MySQL as a database, Eclipse as an IDE for compiling and the Tomcat 7 server
Manipulation of war fie contents
Manipulation of war fie contents  How can I manipulate a specific file inside my war file without extracting it? Please help... Thanks and regards, Swapnil
Error in connecting to the mySQL database in TOMCAT using more than one PC (database connection pooling)
Error in connecting to the mySQL database in TOMCAT using more than one PC...="com.mysql.jdbc.Driver" url="jdbc:mysql://10.9.58.8:3306/alcs_htht"/> </Context>... to successfully connect using one PC. But when I use another PC to access
jsp/mysql connection
jsp/mysql connection  I am puttng the following files in the lib folder of jdk to connect jsp and mysql and in the lib folder of tomacat and in the lib folder of project of netbeans but I am unable to to connect jsp and mysql
jsp/mysql connection
jsp/mysql connection  I am puttng the following files in the lib folder of jdk to connect jsp and mysql and in the lib folder of tomacat and in the lib folder of project of netbeans but I am unable to to connect jsp and mysql
tomcat jsp call DLL
tomcat jsp call DLL  Where can i find Example of use JSP under Tomcat environment call DLL
upload csv to mysql db using jsp upload
upload csv to mysql db using jsp upload  Hello all, Please give me the code to uplad .csv from jsp page and insert values into MySQl db. I have a table with 8 cloumns.(MDN--varchar(30),Otafdate date,crt varchar(30),dmdn
connecting jsp to mysql - JSP-Servlet
connecting jsp to mysql  Hi, i am working on 'Web application development' project that uses JSP, MySQL and tomcat.i am not able to connect to the mysql database through jsp. After downloading the mysql-connector-java-5.0  
insert excel sheet into mysql as a table
insert excel sheet into mysql as a table  sir, i want to import an excel sheet into mysql5.0 database as in the table format using tomcat 6.0 by jsp

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.