JSP-jdbc validation

JSP-jdbc validation

View Answers

September 1, 2008 at 4:29 PM

Hi frined,

<html>
<title>login application in jsp</title>
<head>

<script type="text/javascript">

function validateForm(theForm){



if(theForm.userid.value==""){

//Please enter username

alert("Please enter User Name.");

theForm.userid.focus();

return false;

}
if(theForm.password.value==""){
//please enter passward
alert("Please enter Password.");
theForm.password.focus();
return false;
}

return true;
}
</script>
</head>

<body>

<table border="1" width="50%" bgcolor="pink">
<tr>
<td width="100%">
<form method="POST" action="loginAction.jsp" onsubmit="return validateForm(this);">

<h2 align="center">login page</h2>
<table border="1" width="100%">
<tr>
<td width="50%"><b>User Name:</b></td>
<td width="50%"><input type="text" name="userid" size="20"/> </td>
</tr>
<tr>
<td width="50%"><b>Password:</b></td>
<td width="50%"><input type="password" name="password" size="20"/> </td>
</tr>

</table>
<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset"></p>

</form>
</td>
</tr>
</table>

</body>
</html>

September 1, 2008 at 4:30 PM

login action


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

<%
Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String password="amar123";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);
try{
Statement st = con.createStatement();
String user=request.getParameter("userid");
String pass=request.getParameter("password");
ResultSet rs=st.executeQuery("select userid,password from login");
while(rs.next()) {
String userid =rs.getString(1);
String passw=rs.getString(2);
if(user.equals(userid) && pass.equals(passw)) {
session.setAttribute("user",user);
%>
<jsp:forward page="LoginSuccess.jsp" />

<%}
else
out.println("Login Failed,Please try Againe");
%>

<%
}
}catch(Exception e1){}
}
catch (Exception e){
e.printStackTrace();
}

%>

-----------------------------------------------


Read for more information.

http://www.roseindia.net/jsp/valid-email-jsp.shtml

Thanks.

September 1, 2008 at 7:32 PM

dear friend,
thank you for posting the code. It is working well and I understood the logic. Thanks a lot!

thanks!









Related Tutorials/Questions & Answers:
JSP-jdbc validation - JSP-Servlet
JSP-jdbc validation  How to validate login email id using JSP, where..., login application in jsp function validateForm(theForm... for more information. http://www.roseindia.net/jsp/valid-email
Query regarding JSP, JDBC
Query regarding JSP, JDBC  can I get the code for the question asked by me regarding JSP,JDBC
Advertisements
Jsp,JDBC - JDBC
Jsp,JDBC  Write a Program using Servlet,JSP, JDBC and XML to create a web application for a courier company to provide an online help in tracking the delivery status of items.  Hi friend, For solving the problem
jsp jdbc Spring
jsp jdbc Spring  I need to create the form in jsp with one field.The field is user id. On submitting the form all the details associated... how to link the user id field of jsp with the database using spring mvc
jsp-jdbc - JDBC
jsp-jdbc  Hi! html- jsp-jdbc program from the html form where... jsp frequently. I am getting error through request.getParameter(). can you please...="DriverManager.getConnection("jdbc:odbc:ashokdb","scott","tiger"); Statement st
Help on JSP and JDBC - JDBC
Help on JSP and JDBC  Retrieve data from Database in JSP and JDBC...;% Connection con = null; String url = "jdbc:mysql://localhost:3306/"...;hi friend, jsp only for view , we should use for presentation don t
servlets and jsp - JDBC
servlets and jsp  I want to display textboxes dynamically in my page using JSP and servlets (javascript for validation). For eg, consider the recruitment application form for various jobs. The name, address and tel
courier management service (using servlets,jsp,jdbc)
courier management service (using servlets,jsp,jdbc)   is anyone having information about courier management service ? plz share it .its urgent THANKING YOU IN ADVANCE
validation
validation  validation
jsp - JDBC
jsp - JDBC
variable. JSP Page... Login SuccessfulADS_TO_REPLACE_1 <%-- <jsp:forward page...)action.jsp: JSP Page Hello Login SuccessfulADS_TO_REPLACE_2 Login
jsp - JDBC
jsp  how to link jsp code with next htmlcode.  Hi keerthi, Can u explain ur question clearly? What is your exact Requirement
jsp - JDBC
: Unable to compile class for JSP An error occurred at line: 20 in the jsp file...\localhost\Airlines-Project\org\apache\jsp\Flightdetails_jsp.java:69: cannot find symbol symbol : variable src location: class org.apache.jsp.Flightdetails_jsp
jsp - JDBC
jsp  -------------------------------------------------------------------------------- how to receive data into jsp from html for dropdown boxes
jsp - JDBC
about update at http://www.roseindia.net/jsp/implement-javascript
jsp - JDBC
JSP Storing Data, Datatype vale in SQL   Storing Data, Datatype vale...;<%Connection con = null; String url = "jdbc:mysql://localhost:3306... to sql database using JSP and Servlet here...http://www.roseindia.net/answers
JSP - JDBC
JSP Store Results in Integer Format  JSP Example Code that stores the result in integer format in JSP  Hi! Just run the given JSP Example...;/b></td><% Connection con = null; String url = "jdbc:mysql
jsp - JDBC
jsp  I have one jsp code.but it is included oracle databse...("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection("jdbc:oracle... = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:oracle","scott","tiger"); I
jsp - JDBC
jsp - JDBC
jsp  i am doing project in java using jsp as font end and microsoft access as back end my project airline ticketing reservations how can i give hyperlink to database rows in jsp code.   First
JSP,JDBC and HTML(Very Urgent) - JSP-Servlet
JSP,JDBC and HTML(Very Urgent)  Respected Sir/Madam, Thanks... details from database using JDBC and JSP. The home page i.e HTML Page must contain... the code: I am not using any html. I used only jsp & jdbc. HOme Page
validation
validation  we are doing payroll system project in java.So pls provide the complete validation code for employee master form
validation.....
validation.....  hi.......... thanks for ur reply for validation code. but i want a very simple code in java swings where user is allowed to enter only numerical values in textbox , if he enters string values then it should
is it necessary to have depth knowledge on servlets jsp and jdbc to learn java frameworks
is it necessary to have depth knowledge on servlets jsp and jdbc to learn java... knowledge..my question is do i need to have depth knowledge of servlets jsp and jdbc..plz reply me asap at [email protected]
validation
Validation method valid the in put. otherwise call the javascript onsubmit to check... code.Ok if you use struts then you can use Validation method valid the in put
Validation
); JLabel label=new JLabel("JTable validation Example",JLabel.CENTER); JPanel panel=new JPanel(); panel.add(scroll); JFrame frame=new JFrame("JTable validation
validation
validation  please help me to check validation for <form> <table class="form"> <tr> <td class="col1"> <label>Sno:</label> </td> <td
JSP and JDBC - JSP-Servlet
JSP and JDBC  Respected sir/Madam, I am R.Ragavendran.. I am in urgent need of programming from roseindia team.. My requirement... for JDBC codings must be present.. NOTE: When User clicks Insert,for example
Help on JSP - JDBC
and search the database from the html file with the help of JSP.  hi...;jdbc:oracle:thin@localhost:1521:xe","scot","tiger"
Servlet and Jsp - JDBC
jdbc,jsp - JDBC
jdbc,jsp   this is my jsp code in this code i have to give hyperlink to database(selected row must be deplay)  Hi keerthi, replace the line
JDBC in JSP - JDBC
JDBC in JSP   Sir, This is the code showing the problem. regards sreejith
Servlet and Jsp - JDBC
Servlets and Jsp - JDBC
JDBC in JSP - JDBC
JDBC in JSP   Sir, This is the code showing the problem. regards sreejith
JDBC in JSP - JDBC
JDBC in JSP  Sir, I got a problem in my jsp page which contains a delete query to delete the fields from MySql DB. The delete query is working.... Regards Sreejith  send me your jsp coding then i can understand what
Servlets and Jsp - JDBC
Servlets and Jsp - JDBC
Servlet and Jsp - JDBC
Displaying Date in jsp - JDBC
in a database.i am getting input value from HTML and i use jsp application to interact with database.My JSP code for inserting Date is below: String dateStr... ----------------------------------------- Read for more information. http://www.roseindia.net/jsp/ Thanks
Servlets And Jsp - JDBC
servlets And Jsp - JDBC
pagination in jsp - JDBC
. Simple pagination in jsp... ------------------   Simple pagination in jsp Simple pagination in JSP Displaying Records
Java JSP - JDBC
Java JSP  JDBC connectivity in JSP?  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/Accessingdatabase-fromJSP.shtml Hope that it will be helpful for you. Thanks
Query regarding JSP, JDBC
Query regarding JSP, JDBC  I have a table in SQL Server database storing some ids and names. In my jsp code a while loop is displaying the list of names from the database as links. I want that on click of a link of name furthur
problem in creating web application using servelet, jsp, jdbc and xml - JSP-Servlet
problem in creating web application using servelet, jsp, jdbc and xml  Using Servlet, JSP, JDBC and XML create a web application for a courrier... the technologies JSP,Servlet and JDBC etc... Thanks
validation files
validation files  If I place validation files in the folder where the action classes are present,will there any error arise
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.  please provide online quiz program coding using jsp, jdbc...").newInstance(); Connection connection = DriverManager.getConnection("jdbc:mysql
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
value is inserted into the sql table through jsp-jdbc but not getting stored into the data base,only row is increasing.
value is inserted into the sql table through jsp-jdbc but not getting stored..."> <title>JSP Page</title> <style type...=DriverManager.getConnection("jdbc:oracle:thin:@Nayna-PC:1521:orcl","scott","tiger

Ads