Solved

Jsp beginner

Posted on 2001-06-26
11
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses

623 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