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



Home Answers Viewqa JSP-Servlet JSP-jdbc validation

Have Programming Question? Ask it here!
 
 
 


krishna
JSP-jdbc validation
3 Answer(s)      5 years and 11 months ago
Posted in : JSP-Servlet



Advertisement
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
validation
validation  validation
Advertisements
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
Query regarding JSP, JDBC
Query regarding JSP, JDBC  can I get the code for the question asked by me regarding JSP,JDBC
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 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  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 - 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
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
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 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 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
about update at http://www.roseindia.net/jsp/implement-javascript
jsp - JDBC
jsp  -------------------------------------------------------------------------------- how to receive data into jsp from html for dropdown boxes
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 link jsp code with next htmlcode.  Hi keerthi, Can u explain ur question clearly? What is your exact Requirement
jsp - JDBC
variable. JSP Page... Login Successful <%-- <jsp:forward page="studenthome.jsp"/>...   2)action.jsp: JSP
validation files
validation files  If I place validation files in the folder where the action classes are present,will there any error arise
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
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
form validation
form validation  how the form validation is done in jsf form using javaScript
NSURL Validation
NSURL Validation  How to validate a NSURL string using special character validation
validation query
validation query  where I should kept properties file inside struts Web application
Validation - Struts
Validation  what is the best way to use validation in Struts?either "validation.xml" or JavaScript
Validation of datepicker
Validation of datepicker  I have a datepicker in my JSp...the seleted dates are put in a text box. I want the alert the user from selecting future... a future date is entered..How to do this validation in javascript or jsp
email validation
email validation  during email validation.... after domain name which it means if example example@gmail.co .... this address allowed by any validation program .... but i want to show invalid email address because domain name com
email validation
email validation  during email validation.... after domain name which it means if example example@gmail.co .... this address allowed by any validation program .... but i want to show invalid email address because domain name com
Date Validation
Date Validation  Hi, I need Date Validation using java in spring framework. Please Anyone help me... Thanks in advance
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
Form Validation
Form Validation  Java script validation for checking special characters and white spaces and give an alert.Please help me urgent Thanks in advance
date validation
date validation  sir, pls provide date validation code in javascript..we want to include it into our master form..   Please visit the following link: http://www.roseindia.net/mysql/datevalidation.shtml
validation - Framework
validation  how to validate the action forms in struts? could you please explain how cross validation is done for date?  You go the following url: http://www.roseindia.net/struts/struts-login-form.shtml
Struts validation
Struts validation  I want to put validation rules on my project.But... validation rules,put the plugins inside strutsconfig.xml, put the html:errors tag in jsp,and also mention all the messages in the applicationresources.properties.
Validation - Struts
Validation  How can i use validation framework i don't understand am...; Hi friend, Phone validation using javaScript function... return true; } Phone Validation
Validation doubt
Validation doubt  hi..... thanks for the other validation code. I have got that and implemented in my code but i have a doubt in that. As we try to put string values its not allowing to do tht it gives us message its right
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 mnreddy.nv@gmail.com
validation
form using spring ,hibernate and jsp my all classes and jsp pages are pasted..." prefix="form"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix
Advertisements
 

 

 

DMCA.com