jsp-oracle validation

jsp-oracle validation

View Answers

October 1, 2008 at 2:54 PM

Hi friend,


Implement validation code.


<html>
<title>Insert into database</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" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<form method="POST" action="/examples/jsp/LoginAction" 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>

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

Visit for more information.

http://www.roseindia.net/jsp/

Thanks.

Amardeep

October 1, 2008 at 3:18 PM



Hello

I am try so many times and test different value , but not getting any kind of error.

But one thing,,,,,,,,

statement tryagain try again printed lot of times
so, coding style remove if block from while block. put it separately after while block.

inside first catch block correct e to e1.



Rajanikant
============

October 1, 2008 at 3:29 PM

This is login action code,


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


<%



String userid = request.getParameter("userid");

String password = request.getParameter("password");



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 pass="amar123";

try {

Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,pass);

Statement st = con.createStatement();

String strQuery = "select * from login where userid='"+userid+"' and password='"+password+"'";

out.println(strQuery);

ResultSet rs = st.executeQuery(strQuery);



while(rs.next()){

if((rs.getString(1).equals("admin")) && (rs.getString(2).equals("admin")))

{

session.setAttribute("userid",userid);

response.sendRedirect("userForm.jsp");
}


else{

response.sendRedirect("loginForm.jsp");

}


}

System.out.println("Connected to the database");

con.close();



} catch (Exception e) {

e.printStackTrace();

}

%>


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









Related Tutorials/Questions & Answers:
jsp-oracle validation - JDBC
jsp-oracle validation  Dear friends, my validation not takes place.... --------------------------------------- logoutaction.jsp --------------------------------------- oracle 10g..., Implement validation code. Insert into database function
JSP-Oracle connectivity
JSP-Oracle connectivity  I have created a "dynamic web project" mainly with jsp files in eclipse and now, want to connect with oracle 10g, so how can I proceed for the database connection
Advertisements
how to connection jsp to oracle database connections in netbeans ide
how to connection jsp to oracle database connections in netbeans ide  how to connect jsp to oracle database connections in netbeans ide?pls provide screenshots if possible
how to connection jsp to oracle database connections in netbeans ide
how to connection jsp to oracle database connections in netbeans ide  how to connect jsp to oracle database connections in netbeans ide?pls provide screenshots if possible
Upload and display image and text records using JSP and Oracle
Upload and display image and text records using JSP and Oracle  Hi all, I'm using JSP and Oracle 10g. I could retrieve and display records from database. But i couldnot retrieve and display image. I want to store
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data..
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data... properties file JNDI_NAME=java:com/env/Oracle/jndi db.login= db.password= driver=oracle.jdbc.driver.OracleDriver url=jdbc:oracle:thin:@192.168.100.20
error in uploading image from jsp to oracle 10g database
error in uploading image from jsp to oracle 10g database  java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested when i... please advice how to get rid of error   JSP upload image in Mysql database
validation
validation  validation
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
how to read data from excel file through browse and insert into oracle database using jsp or oracle???
how to read data from excel file through browse and insert into oracle database using jsp or oracle???  sir.. i have number of excel sheets which...://www.roseindia.net/answers/viewqa/JSP-Servlet/28123-write-excel-file-into-the-oracle
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
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
form validation
form validation  how the form validation is done in jsf form using javaScript
Validation - Struts
Validation  what is the best way to use validation in Struts?either "validation.xml" or JavaScript
validation query
validation query  where I should kept properties file inside struts Web application
NSURL Validation
NSURL Validation  How to validate a NSURL string using special character validation
email validation
email validation  during email validation.... after domain name which it means if example [email protected] .... 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 [email protected] .... this address allowed by any validation program .... but i want to show invalid email address because domain name com
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
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
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
Date Validation
Date Validation  Hi, I need Date Validation using java in spring framework. Please Anyone help me... Thanks in advance
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
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
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
Server side validation vs client side validation
Server side validation vs client side validation  Can any one tell me the difference between these two different ways of Validation? Also features of Server side validation vs client side validation.   The client side
Struts2 validation Procedure
Struts2 validation Procedure  In struts2 Which one is best XML Validation or Programatic validation? and which one is used in real world application
Struts2 validation Procedure
Struts2 validation Procedure  In struts2 Which one is best XML Validation or Programatic validation? and which one is used in real world application
Struts2 validation Procedure
Struts2 validation Procedure  In struts2 Which one is best XML Validation or Programatic validation? and which one is used in real world application
validation
Validation
Validation
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
Validation
Validation
Validation
validation
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
javascript validation
validation and for email field it will check formate useing regularexpressions...;html    Email Validation function checkEmail... your question properly..   validation for name it is useful try
Struts 2 - Validation - Struts
Struts 2 - Validation annotations  digging for a simple struts 2 validation annotations example
string validation in php - PHP
string validation in php  Can you please post a example of PHP Built-in String Validation Functions
validation error value is not valid
validation error value is not valid  How to recognize and throw error like "validation error value is not valid
Struts2 validation Procedure
Struts2 validation Procedure  In struts2 Which one is best XML Validation or Programatic validation? and which one is used in real world application?   Hi, Mostly it is programmatic validation is used. In care
form validation
want validation code,username minimum 8 char,password length must >6,and one

Ads