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




Have Programming Question? Ask it here!
 
 
 


maithri
message box
1 Answer(s)      3 years and 6 months ago
Posted in : JSP-Servlet


How to show the message "invalid username and password" after redirecting the page to the login form?


Advertisement
View Answers

February 28, 2011 at 4:06 PM


JSP Login validation

1)login.jsp:

<html>
<script>
function validate(){
var username=document.form.user.value;
var password=document.form.pass.value;
if(username==""){
 alert("Enter Username!");
  return false;
}
if(password==""){
 alert("Enter Password!");
  return false;
}
return true;
}
</script>
<form name="form" method="post" action="check.jsp" onsubmit="javascript:return validate();">
<table>
<tr><td>Username:</td><td><input type="text" name="user"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>
<%String msg=request.getParameter("msg");
if(msg!=null){
    %>
<label><font color="red"><%=msg%></font></label> 
<%
}
    %>

2)check.jsp:

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

<%
String user=request.getParameter("user");
String pass=request.getParameter("pass");
 Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from login where username='"+user+"' and password='"+pass+"'");
int count=0;
          while(rs.next())
          {

                   count++;
          }

                    if(count>0)
          {
            out.println("welcome "+user);
          }
          else
          {
                       response.sendRedirect("login.jsp?msg=Invalid Username or Password");
          }
%>


Related Tutorials/Questions & Answers:
message box
message box  How to show the message "invalid username and password" after redirecting the page to the login form
Changing the message box to a specific color
Changing the message box to a specific color  How do you change the message box color to a specific color? I can get the color to change with each... the message box to red but its not really working. Can you help me
Advertisements
Java Message Box - Java Beginners
Java Message Box  I want to display the variable value in message box...); But the message box display nothing. Is there any way to display the value of s in message box. Please help me as soon as possible.  Hi
Java Message Box
Java Message Box In this tutorials you will learn about how to create Message Box in Java. Java API provide a class to create a message Box in java. By message box we mean a box in which message is displayed or a box from which input
Message Box Java
In this section we will create a message box in Java using a Java API class. A certain message, warning or information can be displayed in this message box. Generally the message box is used to display error message. JOptionPane class
confirm message box - Java Beginners
confirm message box  How can I create a confirm message with Yes and No button instead of OK/Cancel buttons in java script inside a jsp?   ... Title', 'My Confirm Message', 2,0,0) if (retVal==true) return true; else
Show message and confirm dialog box
Show Message and Confirm Dialog Box - Swing Dialogs... types of message box. There are three types of message dialog box that you can.... Once you click on the first button then the simple message box will open which
input ang message box - Java Beginners
Boxes. Show the result with Message Dialog Boxes. Set the Message Dialog Box Type to Information Message.  Hi Friend, Try the following code: import...input ang message box  can you help me to calculates for the sum
how to add save,discard,& cancel button in a message box - Struts
how to add save,discard,& cancel button in a message box  how to add save,discard,& cancel button in a message box
how do you change the message box to a specific color
how do you change the message box to a specific color  How do you change the message box color to a specific color? I can get the color to change... the message box to red but its not really working. Can you help me
Show Dialog Box in Java
;    Message dialog box is used to display informative... the message Dialog box. Our program display "Click Me" button on the window and when user clicks on it program displays Message box with "OK"
Flex Alert Box example
Flex Alert Box example       Alert box is a dialog box that appears on window with some message and stays rigid until the event associated with it is not done. Alert
Java Alert Box
JOptionPane class to display the message alert box.  JOptionPane class is available...Java Alert Box In this example we will describe java alert box. First of all we have created class than main method after that we have created alert box
difference between $message and $$message
difference between $message and $$message  What is the difference between $message and $$message?   Hi friends, $message is a simple variable whereas $$message is a reference variable. Example: $name = 'Bharat
What is the difference between $message and $$message?
What is the difference between $message and $$message?  What is the difference between $message and $$message
message passing
message passing  how message is passed using jade technology
Hollow Box
Hollow Box  Write an application program that will draw a hollow box (a box with empty space in between). The program will ask the user to key in a whole number larger or equals to 5. An error message would appear if the user
Display alert box on clicking link
Display alert box on clicking link In this tutorial, we will display alert box to prompt message using jQuery. In the below program , html page contains a "a href" link. On clicking this link ,a alert box prompt message
Java Message Services - JMS
Java Message Services  What is Java Message Services
Objective C Message Passing
Objective C Message Passing  What exactly a message passing means in Objective C? and how can i pass a message to a method
Javascript alert message
Javascript alert message   How to send an alert message to a user in JavaScript
Message Context in AXIS
Message Context in AXIS  Is there any method in Axis classes to het the size of IN and OUT Message Conetext
Message Resource Bundle work.
Message Resource Bundle work.  How does Value replacement in Message Resource Bundle work
input box
input box  give me the code of input box in core java
input box
input box  give me the code of input box in core java
HTML in the box
HTML in the box  Can I use any HTML in the box
how to send message
how to send message  how to send message for mobile in server
javascript dom error-message
javascript dom error-message  javascript dom error-message
websphere message broker - WebSevices
websphere message broker  how can i find the heapsize of the execution group in the message broker using command console syntax
soap message console - WebSevices
soap message console  hi friends i have one doubt that is iam using MyEclipse 6.0 in that how do i get soap message console
GETTING ALERT MESSAGE
GETTING ALERT MESSAGE  how to get an alert message when radio button is selected instead of checkbox
select box and text box validations
select box and text box validations  hi, any one please tell me how to set validations for select box and text boxes using bean classes? thank you   Please visit the following link: http://www.roseindia.net/jsp/user
message driven bean example
message driven bean example  can any one tell me how to develop and execute ---------- j2ee message driven bean example in weblogic server with (netbeans or eclipse).   Have a look at the following link: http
GETTING AN ALERT MESSAGE
GETTING AN ALERT MESSAGE  how to get an alert message, if i select radio button instead of checkbox(associated with 3 dropdown list
forward error message in struts
forward error message in struts  how to forward the error message got in struts from one jsp to other jsp?   Hello Friend, Use <%@ page.... The code errorPage="errorPage.jsp" forwards the exception message
A Message-Driven Bean Example
A Message-Driven Bean Example   ... messages asynchronously,  a Message-driven bean is used. Message driven..., email or IM messages). In message driven beans, the messaging service
validation message - Struts
validation message  sir, i took help of that example but in that we change only color of the message i want to shift the place of the error message.means all messages are put together at top of the form
pop up message in java
pop up message in java  hii..i have developed an application in which a login and registration form is there.when the registration is done the user... an automatic message to change the password.how is it done??the forms are done using java
msg box in jsp
msg box in jsp  i need the source code to display the msgbox in jsp....but one condition is,i need to use it in the current page itself...now i use the message box means it prints it into another page...i need to resolve it plz
Popup dialog box in java
dialogs-user can customize dialog box. Here is a simple popup message dialog box...Popup dialog box in java  How to display popup dialog box in java?   Dialog Box- A dialog box is an independent small window which appear
dropdown box
dropdown box  i need to have country,state and city in drop down box using ajax and use db2 database   Have a look at the following link: JSP dependent dropdown
dialog box
dialog box to ask to quit or continue  hello. write an application that displays a series of at least four interview questions and each question... of the interview, use a dialog box to ask whether the user wants to - enter another set
dialog box
dialog box to show latest question  hello. write an application that displays a series of at least four interview questions and each question should... of the interview, use a dialog box to ask whether the user wants to - enter another set
combo box
combo box  Hi, [_|] dropdown box [ ] [INCLUDE... a screen like this using jsp-servlet(or DAO,DTO),in that drop down box i should get
error message - Java Beginners
error message  sir, while i m trying to execute my first program(print my name)I get error message like" javac is not recognized as internal or external ...blah..blah..or batch file".even i hav tried setting the path variable
JSF message Tag
JSF message Tag      In this section we will explain you JSF message tag. This is used to display the most recent message for the component. This is used to show the message
dialog box
dialog box  hello. write an application that displays a series of at least four interview questions and each question should have at least three possible numeric choice answers. at the end of the interview, use a dialog box
dialog box
dialog box  hello. write an application that displays a series of at least four interview questions and each question should have at least three possible numeric choice answers. at the end of the interview, use a dialog box
dialog box
dialog box  hello. write an application that displays a series of at least four interview questions and each question should have at least three possible numeric choice answers. at the end of the interview, use a dialog box
dialog box
dialog box  hello. write an application that displays a series of at least four interview questions and each question should have at least three possible numeric choice answers. at the end of the interview, use a dialog box
 

 

 

DMCA.com