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



Home Answers Viewqa JSP-Servlet JSP basic doubt

Have Programming Question? Ask it here!
 
 
 


GRR
JSP basic doubt
3 Answer(s)      3 years and 8 months ago
Posted in : JSP-Servlet


String user = request.getParameter("username");

in this "user" value is null or not how to validate? before going further action.


Advertisement
View Answers

December 13, 2010 at 5:11 PM


Hi Friend,

Either you can do the following :

1)login.jsp:

<%@page import="java.sql.*"%>
<html>
<form method="post" action="check.jsp">
<table>
<tr><td>Username:</td><td><input type="text" name="user"></td></tr>
<tr><td>Password:</td><td><input type="text" name="pass"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)check.jsp:

<%
String user=request.getParameter("user");
String pass=request.getParameter("pass");
if(user.equals("")&&pass.equals("")){
    response.sendRedirect("login.jsp");
}
else{
}
%>

Or you can use JavaScript for validation like this:

<%@page import="java.sql.*"%>
<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="text" name="pass"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>


December 13, 2010 at 5:53 PM


Hi Friend,

How to get the message in login.jsp like "username or password is wrorng"



December 13, 2010 at 7:08 PM


Once validating in check.jsp, i want error message on login.jsp like 'username or password is not provided' if username or password is null.

How get above thing.



Related Tutorials/Questions & Answers:
JSP basic doubt
JSP basic doubt  String user = request.getParameter("username"); in this "user" value is null or not how to validate? before going further action.   Hi Friend, Either you can do the following : 1)login.jsp: <
Jsp doubt
Jsp doubt  In Employee.jsp form, When i click employee id value in combo box , how i get the related employee name will be displayed in text field? i already stored combo box values from database
Advertisements
Doubt regarding charts and jsp
Doubt regarding charts and jsp  Hi, I successfully executed... in web application(jsp). So,please help me out in how to connect the normal java application output to an jsp page? thanks in advance   Put the jar
JSP Doubt - JSP-Servlet
JSP Doubt  Hello Sir, Sir Actually I have created my DraftAd in Html and I want that any thing i type in draft ad should be converted into digits i.e integers and should get displayed in another text box ie count text box
Doubt regarding charts and jsp
Doubt regarding charts and jsp  Hi in the http://www.roseindia.net/chartgraphs/barchart-jsppage.shtml of the code (new StandardEntityCollection()); final File file1 = new File("../webapps/jspchart/web/barchart.png
Doubt in servlets - JSP-Servlet
Doubt in servlets  Good Evening sir/madam, I want to add data dynamically for that which methods i have to use to retrieve the dynamic data .  Hi Friend, Try the following code: 1
I have doubt in jsp file.
I have doubt in jsp file.  I have doubt in jsp file. In a jsp file, there should be two buttons. One is start and other is stop. When we click on start then only stop should be enabled. Other wise it should be disabled. When
doubt this
doubt this  what is the use of "this" and "super" keyword
DOUBT ?
DOUBT ?  in c++ member function of a class must be public
Clarify my doubt - JSP-Servlet
Clarify my doubt  Hi All, Although i know the concept of Servlet & JSP, but I have never got a chance to work in EJB . So could u please tell me how... project in netbeans adding jsp/servlet in this web project and deploying
Doubt
Doubt  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details
Doubt
User request form  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action="page2.html
Doubt
How to load page  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action="page2.html
Doubt
Submit and process form  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action
Doubt
load next page after submitting  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action
Doubt in using combination of JSP page and Java class. - JSP-Servlet
Doubt in using combination of JSP page and Java class.   I've got... be disabled from clicking. How to go about doing this in a "JSP Page using... the data in form bean and used in jsp file.  Well first of all thank
Basic problem but very urgent - JSP-Servlet
Basic problem but very urgent  Respected Sir/Madam, I am R.Ragavendran.. Thanks for your superb reply. I got the link you sent. But I find a simple... kind reference. http://www.roseindia.net/jsp/popup-window-using-ajax
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... think i am able to tell u what i want to and u have got whats my doubt. plz give
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how to integrate struts with hibernate,any predifined plugin is available or we need to create our own plugin????? and please help me. how to use dao s while integrating
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how to integrate struts with hibernate,any predifined plugin is available or we need to create our own plugin????? and please help me. how to use dao s while integrating
basic login and registration web page using jsp and servlet without using bean .....
basic login and registration web page using jsp and servlet without using bean .....  Hello Folks please i m totally beginner so guys please help me with very simple solution..... thnx
Doubt in struts - Struts
Doubt in struts  I am new to Struts, Can anybody say how to retrieve data from database and display it in jsp. Some said to use beans but i dont... : http://www.roseindia.net/jsp/paging.shtml Thanks
java beginners doubt!
java beginners doubt!  How to write clone()in java strings
doubt about J2EE connetivity
doubt about J2EE connetivity  steps to connect J2EE components with MYSQL
basic html
basic html  what is the difference between html4 and html5
basic question
basic question  how we create a new table with the same structure and data of another table
doubt in struts - Struts
doubt in struts   i don't understand the concept on Resource bundle in struts can u please help me out
basic doubts
basic doubts  can i write two beans within a same xml file..? Also can i write two xml files within a same package
basic program
basic program  hii actully i am goin for technical interview on java as fresher so please tell me what these two basic lines means : public static void main(String arg) and System.out.print(); please give me meaning of each
A basic program
A basic program  Write a program that will print out the first 10 numbers, their squares and their cubes. Write a program that displays the first 100 terms of the triangular sequence. This is the sequence that goes
doubt regarding JSF
doubt regarding JSF  Hi, pls explain what is difference between struts &JSF? pls explain what is difference between SPRING &JSF
String doubt replace function
String doubt replace function  What is the output and why of below : String s1 = "Hello"; if(s1.replace('H','H')== "Hello") System.out.println("yes"); else System.out.println("No"); if(s1.replace("H", "H")== "Hello
Doubt Regarding Charts
Doubt Regarding Charts  Hi, Can you please help me out by answering "hoe to include charts in core java code and struts code" thanks in advance, Swaroop Eswara   Please visit the following link: Jfreechart
"Doubt on Swing" - Java Beginners
"Doubt on Swing"  Hi Friend.... Thanks for ur goog Response.. i need to create a GUI Like... pic1.gif RadioButton pic2.gif RadioButton Pic3.gif RadioButton If we have select d appropriate radio
doubt - Date Calendar
doubt about retrieve dates from Database  Retrieve dates from... from the database with some condition in dates in jsp   Retrieve data from Database using JSP JSP Example Code for retrieving Data from Database<
DOubt in Mysql connections
DOubt in Mysql connections  i have some problem regarding data base connections, i have created a hostname, username and password in filezilla server but after i give those names also it is showing error like this: mysql
Doubt on Segmentation - Java Beginners
Doubt on Segmentation  Hi .. ImageProcessing.. How to segment the each and every characters from the bitmap image Consider for an example bitmap1.bmp: Visuallc++ text is on bitmap1.bmp..How to extract those from image
Doubt about Xstream Converter
Doubt about Xstream Converter  Hi, I am using the Xstream freamwork to read a lot of files in a batch operation. I use a custom converter Xstream to read some properties of my Xml file, but when I changed my application
doubt about JMS selector
doubt about JMS selector  Hi! , i have a little problem with message selector in JMS api. I'am try develop a request and response with JMS queue, but I didn├?┬┤t get success. in my case, i send a message to server, server
doubt about JMS selector
doubt about JMS selector  Hi! , i have a little problem with message selector in JMS api. I'am try develop a request and response with JMS queue, but I didn├?┬┤t get success. I use this reference site like guide. in my
Doubt In Sql query
Doubt In Sql query  Hi Have a glance @ http://img98.imageshack.us/img98/4348/tableo.png For a single country there may be n numbers of country_notes. I Need to fetch all the distinct records of countries with the latest country
doubt on synchronized block in java
doubt on synchronized block in java  Hi ! some people are feeling bore on my regular questions on threads. Do not feel bore on my regular questions.I.... I think you got my doubt. I request you to clarify my doubt based on below
Advertisements
 

 

 

DMCA.com