Solved

Jsp beginner

Posted on 2001-06-26
11
283 Views
Last Modified: 2010-03-31
Hi,

I'm after a simple jsp example for single user(No database used).

1)user logs in with valid login/pw using login.jsp
2)it gets redirected to welcome.jsp, where session object gets established and expires after 60 sec(gets back to login.jsp).

Can anyone supply me this example ASAP, Its important as part of my assignment...

Thanks in advance



0
Comment
Question by:bangviz
  • 6
  • 3
  • 2
11 Comments
 
LVL 1

Author Comment

by:bangviz
ID: 6230029
I was after a JSP and servlet form processing
0
 
LVL 1

Author Comment

by:bangviz
ID: 6230047
I was after a JSP and servlet form processing
0
 
LVL 10

Expert Comment

by:Nushi
ID: 6232986
hello bangviz .

i have a similar thing i have at work so if you will place here comment tommorow i will get at my desktop and i will sent you what u need.

Nushi.

0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 1

Author Comment

by:bangviz
ID: 6233384
That should be fine....i'm awaiting for it...
bangvizau@yahoo.com.au
0
 
LVL 10

Expert Comment

by:Nushi
ID: 6234059
bangviz hello again.

i need to ask you some things:

1. where do you get password from?
do you use bean or is it in another Jsp page?

Nushi.
0
 
LVL 10

Accepted Solution

by:
Nushi earned 300 total points
ID: 6234487
here is a sample code which i will fix for your need.
just let me know what u want me to do and ill help you as much as i can.
feel free to ask me anything which is not clear of if you want to know more.

there are 3 files:
login.jsp  (where you enter username and password)
login2.jsp (where we check user.password
welcome.jsp (welcome page which will be refreshed after X seconds)

-----------------   login.jsp   -----------------------

<html>
<head>
     <title>login.jsp</title>
</head>

<body>
<table border="2">
<tr>
     <td><FONT color=#ff0000><STRONG>file name: login.jsp</STRONG></FONT></td>
</tr>
</table>

 

im sending you only the code that you would need.
i assume that you know html and will fix the form for your needs

<P>&nbsp;</P>
<form name="form1" method="post" action="login2.jsp">
<TABLE>
  <TR>
    <TD><STRONG><FONT face=Arial>Name</FONT></STRONG></TD>
    <TD><input name="username" id="username" value="username" ></TD>
  </TR>
  <TR>
    <TD><FONT face=Arial><STRONG>Password</STRONG></FONT></TD>
    <TD><input type="password" name="password" id="password" value="password"></TD>
  </TR>
  <TR>
    <TD></TD>
    <TD></TD>
  </TR>
</TABLE>
<input type="submit" name="submit" value="Submit ">
</form>



</body>
</html>


-----------------   login2.jsp   -----------------------
<html>
<head>
     <title>login2.jsp</title>
</head>
</script>
<body>
<table border="2">
<tr>
     <td><FONT color=#ff0000><STRONG>file name: login2.jsp</STRONG></FONT></td>
</tr>
</table>


<%
// this will be the params that u confirm with:
final String userValue="username";
final String passValue="password";

String userParam="";
String passParam="";

//this if will retrive information when you press submit in the login.jsp
if (request.getMethod().equals("POST")){
     userParam = request.getParameter("username");
     passParam = request.getParameter("password");
     
     out.println("<strong>");
     out.println("<br>Username : "+ userValue);
     out.println("<br>Username entered: "+ userParam);

     out.println("<br><br>Password : "+ passValue);
     out.println("<br>Password entered: "+ passParam );
     out.println("</strong>");
     
     //here we will check validation of user/password
     if (!userValue.equals(userParam) || !passValue.equals(passParam))
          out.println("<br><br><font color=#000080>Wrong user name and/or password</font>");
     else
          response.sendRedirect("Welcome.jsp");
     }
     
%>

</body>
</html>


-----------------   welcome.jsp   -----------------------
change the refresh to any number you want and also the var timeout.

<html>
<meta http-equiv="Refresh" content="60;URL=login.jsp">
<head>
     <title>Welcome</title>
</head>

<body onload="clockTick()">
<table border="2">
<tr>
     <td><FONT color=#ff0000><STRONG>file name: Welcome.jsp</STRONG></FONT></td>
</tr>
</table>

this page will be dispalyed only if
you passed user password checking.<br>
you will be redirected to login page in :<br>
<input type="Text" disabled id="time" value="60" size=1 onchange="this.value=setTimeout(this.value ,1000)">
<script language="JavaScript1.2">
var temp=0;
var timeout = 60;

function clockTick(){
     temp = window.setTimeout('clockTick()',1000);
     timeout--
     time.value = timeout
}
</script>
</body>
</html>


Nushi.
0
 
LVL 10

Expert Comment

by:Nushi
ID: 6241964
please let me know what going on.

Nushi.
0
 
LVL 10

Expert Comment

by:Nushi
ID: 6247863
where did you dissapear?
please let me know whats going on.

Nushi.
0
 
LVL 10

Expert Comment

by:Nushi
ID: 6331518
hello?

bangviz why arent you accepting the answer?
its exactly what you was looking for.

i see that u dont belive in grading your questions.
many of your questions are stillopen and they are old.

why would people will want to help you if you dont give them points.

!!!!

Nushi.

0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6801173
bangviz--->  These are you open questions, please update and finalize them as quickly as possible.  If more is needed, let the experts know, if you've been helped please accept the expert comment that helped you to grade and close it.  Administration will be contacting you by Email about your lack of responsiveness to the experts who so willingly help you.  Your account has been escalated.

Experts, please let me know if this is still open in one week, and advise me how to close this ..... Award, PAQ at zero points or Delete.  Thanks in advance.

OPEN AND REQUIRE UPDATES/CLOSURE:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=20091168 - MARCH, 2001
http://www.experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=20123325
http://www.experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=20139009
http://www.experts-exchange.com/jsp/qShow.jsp?ta=dbgen&qid=20067491 JANUARY, 2001
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20142040
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20139228
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20139036
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20125377

Thank you,

Moondancer
Community Support Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6814097
I finalized this today, since Asker logged in 2/17/02, after my request was posted and chose not to respond.  This is now closed.
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
what is a "java.lang.System Property"   ? 20 67
diffSum example 4 37
spring jars download 1 28
runtime exception 2 28
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question