Solved

Jsp beginner

Posted on 2001-06-26
11
279 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
Comment Utility
I was after a JSP and servlet form processing
0
 
LVL 1

Author Comment

by:bangviz
Comment Utility
I was after a JSP and servlet form processing
0
 
LVL 10

Expert Comment

by:Nushi
Comment Utility
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
 
LVL 1

Author Comment

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

Expert Comment

by:Nushi
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 10

Accepted Solution

by:
Nushi earned 300 total points
Comment Utility
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
Comment Utility
please let me know what going on.

Nushi.
0
 
LVL 10

Expert Comment

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

Nushi.
0
 
LVL 10

Expert Comment

by:Nushi
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now