iTech College - Internet Technology, Online Education, E-Learning, Technician Training, Tech Tutorials, Distance Education, Virtual Learning JSP Course: The If Statement - www.itechcollege.com JSP Course: The If Statement - www.itechcollege.com
Free Courses
HTML
JavaScript
CSS
ASP
PHP
JSP
C++
ASP.NET
SQL
AJAX
FTP
XML

courses > JSP > The If Statement

The If Statement

Let's modify the above two pages:

first.JSP:

<html> 
<body> 
<form action="second.JSP" method="post">
User Name: <input type="text" name="user">
Password: <input type="password" name="pass">
<input type="submit" value="Send Query String">
</form>
</body> 
</html>

second.JSP:

<html>
<body>
<%
String u=request.getParameter("user");
String p=request.getParameter("pass");
if ((u.equals("John")) && (p.equals("John123"))) {
out.println "Hi" + u + ", your login is valid.";
}else{
out.println "Sorry, invalid login";
}
%>
</body>
</html>

Open first.JSP on web brower, enter some values as user name and password in the boxes, then submit. You will see, if you entered "John" for the user name and "John123" for the password, then the output on second.JSP is:

Hi John, your login is valid

Otherwise, you will see the message:

Sorry, invalid login

The basic syntax of "If... then..." is:

if (...) {
...
}

You can use "else" or "else if " to make more choices:

if (...) {
...
}else if (...) {
... 
}else{
...
}


  Back to Index Page
 Next Page:  

Introduction
JSP Tags and Include File
println and getParameter
The If Statement
For Loop
Redirect
Session
Use Database
JSP syntax
Scripting elements
Actions


Online Education, Online Training for Your Job, Distance Education, E-learning Programs for Your Career!Online Colleges, Online Universities, E-learning & Distance Education for Your Career! Easy Job Training & Online Courses.


   Email A Friend  
 
Earn Online Degree
for Your Job
I found a job after I earned an online degree!
Online classes for finding a Job. Online College, Online University, Degrees, E-learning school, online certificate Earn your
online degree now!
Online Training
for Good Job
Why I work so hard but earn so little? Why I cannot find a high paying job?
Online training for a Good Jobs. Online Degree, E-learning school, online certificate Go to
online school now!

Copyright ©2024, itechcollege.com. All rights reserved
iTechCollege | About iTech | Contact iTech