Re: Please help me figure out this....

2001-04-02 Thread Johan Fredriksson

Yes, you should not use

return (name=="abc"  passwd=="123 ");

but

return (name.equals("abc")  passwd.equals("123"));

This will probably fix your problem.

Johan

- Original Message -
From: "Roland Dong" [EMAIL PROTECTED]
To: "Orion-Interest" [EMAIL PROTECTED]
Sent: Sunday, April 01, 2001 11:42 AM
Subject: Please help me figure out this



 I have login.html calling a servlet (loginHander) which handles
authorization. If user is validated, the servlet will redirect the user to
Welcome.jsp

 My problem is I could not pass the value of user and password from
login.html to loginHandler.  I set the boolean method loggedIn so that when
user name is
 abc and password is 123 the user should log in.  However, this somehow can
not be accomplished.  Even I entered abc as name and 123 as password, I was
bounced back to login.html page.

 I am using Orion 1.47.

 Please help!

 RB

 //Here is loginHander.java

 import java.io.*;
 import java.util.*;
 import javax.servlet.*;
 import javax.servlet.http.*;

 public class LoginHandler extends HttpServlet {

   public void doPost(HttpServletRequest req, HttpServletResponse res)
 throws ServletException, IOException {
 res.setContentType("text/html");
 PrintWriter out = res.getWriter();

 // Get the user's name and password
 String name = req.getParameter("name");
 String passwd = req.getParameter("passwd");

 // Check the name and password for validity
 if (!loggedIn(name, passwd)) {
   out.println("HTMLHEADTITLEAccess Denied/TITLE/HEAD");
   out.println("BODYYour login and password are invalid.BR");
   out.println("You may want to A HREF=\"/jsp/testing/login.html\"try
again/A");
   out.println("/BODY/HTML");
 }
 else {
   // Valid login.  Make a note in the session object.
   HttpSession session = req.getSession(true);
   session.setAttribute("logon.isDone", name);  // just a marker object

   // Try redirecting the client to the page he first tried to access
   try {

   res.sendRedirect("/jsp/testing/Welcome.jsp");
   return;


   }
   catch (Exception ignored) { }

   // Couldn't redirect to the target.  Redirect to the site's home
page.
   res.sendRedirect(req.getScheme() + "://" +
req.getServerName() + ":" + req.getServerPort());
 }
   }

   protected boolean loggedIn(String name, String passwd) {

 return (name=="abc"  passwd=="123 ");

   }
 }

 //
 //Here is the login.html

 HTML
 TITLELogin/TITLE
 BODY
 FORM ACTION=/servlet/LoginHandler METHOD=POST
 CENTER
 TABLE BORDER=0
 TRTD COLSPAN=2
 P ALIGN=CENTER
 Welcome!  Please enter your NnnnNamebr
  and Password to log in.
 /TD/TR

 TRTD
 P ALIGN=RIGHTBName:/B
 /TD
 TD
 PINPUT TYPE=TEXT NAME="name" VLAUE="" SIZE=15
 /TD/TR

 TRTD
 P ALIGN=RIGHTBPassword:/B
 /TD
 TD
 PINPUT TYPE=PASSWORD NAME="passwd" VALUE="" SIZE=15
 /TD/TR

 TRTD COLSPAN=2
 CENTER
 INPUT TYPE=SUBMIT VALUE="  OK   "
 /CENTER
 /TD/TR
 /TABLE
 /BODY/HTML


 //*
 //Here is the Welcom.jsp


 % if ( session.getValue("userName") == null) { %

 B hello...it is a nullB

 % // here we can give some error message %

 % } else {%

  !--- so this is the authorized user let's display the welcome
  message --- 

 HTML

  HEAD

 B Welcome  %= session.getValue("userName")%

 /B

  /HEAD

 BODY

   !--- all the other stuff --

 /BODY

 / HTML

 %  }   %






RE: Please help me figure out this....

2001-04-01 Thread Meo Van Le

You should use name.equals("123") instead of use name=="abc"

Please make sure that you understand the difference beetween
name.equals("123") and name=="abc"


-Original Message-
From: Roland Dong [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 01, 2001 4:43 PM
To: Orion-Interest
Subject: Please help me figure out this



I have login.html calling a servlet (loginHander) which handles
authorization. If user is validated, the servlet will redirect the user to
Welcome.jsp

My problem is I could not pass the value of user and password from
login.html to loginHandler.  I set the boolean method loggedIn so that when
user name is
abc and password is 123 the user should log in.  However, this somehow can
not be accomplished.  Even I entered abc as name and 123 as password, I was
bounced back to login.html page.

I am using Orion 1.47.

Please help!

RB

//Here is loginHander.java

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoginHandler extends HttpServlet {

  public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();

// Get the user's name and password
String name = req.getParameter("name");
String passwd = req.getParameter("passwd");

// Check the name and password for validity
if (!loggedIn(name, passwd)) {
  out.println("HTMLHEADTITLEAccess Denied/TITLE/HEAD");
  out.println("BODYYour login and password are invalid.BR");
  out.println("You may want to A HREF=\"/jsp/testing/login.html\"try
again/A");
  out.println("/BODY/HTML");
}
else {
  // Valid login.  Make a note in the session object.
  HttpSession session = req.getSession(true);
  session.setAttribute("logon.isDone", name);  // just a marker object

  // Try redirecting the client to the page he first tried to access
  try {
  
  res.sendRedirect("/jsp/testing/Welcome.jsp");
  return;
  
  
  }
  catch (Exception ignored) { }

  // Couldn't redirect to the target.  Redirect to the site's home page.
  res.sendRedirect(req.getScheme() + "://" + 
   req.getServerName() + ":" + req.getServerPort());
}
  }

  protected boolean loggedIn(String name, String passwd) {
   
return (name=="abc"  passwd=="123 ");

  }
} 

//
//Here is the login.html

HTML
TITLELogin/TITLE
BODY
FORM ACTION=/servlet/LoginHandler METHOD=POST
CENTER
TABLE BORDER=0
TRTD COLSPAN=2
P ALIGN=CENTER
Welcome!  Please enter your NnnnNamebr
 and Password to log in.
/TD/TR

TRTD
P ALIGN=RIGHTBName:/B
/TD
TD
PINPUT TYPE=TEXT NAME="name" VLAUE="" SIZE=15
/TD/TR

TRTD
P ALIGN=RIGHTBPassword:/B
/TD
TD
PINPUT TYPE=PASSWORD NAME="passwd" VALUE="" SIZE=15
/TD/TR

TRTD COLSPAN=2
CENTER
INPUT TYPE=SUBMIT VALUE="  OK   "
/CENTER
/TD/TR
/TABLE
/BODY/HTML


//*
//Here is the Welcom.jsp


% if ( session.getValue("userName") == null) { %

B hello...it is a nullB

% // here we can give some error message %

% } else {%

 !--- so this is the authorized user let's display the welcome 
 message --- 

HTML

 HEAD

B Welcome  %= session.getValue("userName")%

/B

 /HEAD 

BODY

  !--- all the other stuff --

/BODY

/ HTML

%  }   %





RE: Please help me figure out this....

2001-04-01 Thread Roland Dong

Thanks for pointing that out

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Meo Van Le
Sent: Sunday, April 01, 2001 1:50 AM
To: Orion-Interest
Subject: RE: Please help me figure out this


You should use name.equals("123") instead of use name=="abc"

Please make sure that you understand the difference beetween
name.equals("123") and name=="abc"


-Original Message-
From: Roland Dong [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 01, 2001 4:43 PM
To: Orion-Interest
Subject: Please help me figure out this



I have login.html calling a servlet (loginHander) which handles
authorization. If user is validated, the servlet will redirect the user to
Welcome.jsp

My problem is I could not pass the value of user and password from
login.html to loginHandler.  I set the boolean method loggedIn so that when
user name is
abc and password is 123 the user should log in.  However, this somehow can
not be accomplished.  Even I entered abc as name and 123 as password, I was
bounced back to login.html page.

I am using Orion 1.47.

Please help!

RB

//Here is loginHander.java

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoginHandler extends HttpServlet {

  public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();

// Get the user's name and password
String name = req.getParameter("name");
String passwd = req.getParameter("passwd");

// Check the name and password for validity
if (!loggedIn(name, passwd)) {
  out.println("HTMLHEADTITLEAccess Denied/TITLE/HEAD");
  out.println("BODYYour login and password are invalid.BR");
  out.println("You may want to A HREF=\"/jsp/testing/login.html\"try
again/A");
  out.println("/BODY/HTML");
}
else {
  // Valid login.  Make a note in the session object.
  HttpSession session = req.getSession(true);
  session.setAttribute("logon.isDone", name);  // just a marker object

  // Try redirecting the client to the page he first tried to access
  try {
  
  res.sendRedirect("/jsp/testing/Welcome.jsp");
  return;
  
  
  }
  catch (Exception ignored) { }

  // Couldn't redirect to the target.  Redirect to the site's home page.
  res.sendRedirect(req.getScheme() + "://" + 
   req.getServerName() + ":" + req.getServerPort());
}
  }

  protected boolean loggedIn(String name, String passwd) {
   
return (name=="abc"  passwd=="123 ");

  }
} 

//
//Here is the login.html

HTML
TITLELogin/TITLE
BODY
FORM ACTION=/servlet/LoginHandler METHOD=POST
CENTER
TABLE BORDER=0
TRTD COLSPAN=2
P ALIGN=CENTER
Welcome!  Please enter your NnnnNamebr
 and Password to log in.
/TD/TR

TRTD
P ALIGN=RIGHTBName:/B
/TD
TD
PINPUT TYPE=TEXT NAME="name" VLAUE="" SIZE=15
/TD/TR

TRTD
P ALIGN=RIGHTBPassword:/B
/TD
TD
PINPUT TYPE=PASSWORD NAME="passwd" VALUE="" SIZE=15
/TD/TR

TRTD COLSPAN=2
CENTER
INPUT TYPE=SUBMIT VALUE="  OK   "
/CENTER
/TD/TR
/TABLE
/BODY/HTML


//*
//Here is the Welcom.jsp


% if ( session.getValue("userName") == null) { %

B hello...it is a nullB

% // here we can give some error message %

% } else {%

 !--- so this is the authorized user let's display the welcome 
 message --- 

HTML

 HEAD

B Welcome  %= session.getValue("userName")%

/B

 /HEAD 

BODY

  !--- all the other stuff --

/BODY

/ HTML

%  }   %






Please help me figure out this....

2001-03-31 Thread Roland Dong


I have login.html calling a servlet (loginHander) which handles authorization. If user 
is validated, the servlet will redirect the user to Welcome.jsp

My problem is I could not pass the value of user and password from login.html to 
loginHandler.  I set the boolean method loggedIn so that when user name is
abc and password is 123 the user should log in.  However, this somehow can not be 
accomplished.  Even I entered abc as name and 123 as password, I was bounced back to 
login.html page.

I am using Orion 1.47.

Please help!

RB

//Here is loginHander.java

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoginHandler extends HttpServlet {

  public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();

// Get the user's name and password
String name = req.getParameter("name");
String passwd = req.getParameter("passwd");

// Check the name and password for validity
if (!loggedIn(name, passwd)) {
  out.println("HTMLHEADTITLEAccess Denied/TITLE/HEAD");
  out.println("BODYYour login and password are invalid.BR");
  out.println("You may want to A HREF=\"/jsp/testing/login.html\"try again/A");
  out.println("/BODY/HTML");
}
else {
  // Valid login.  Make a note in the session object.
  HttpSession session = req.getSession(true);
  session.setAttribute("logon.isDone", name);  // just a marker object

  // Try redirecting the client to the page he first tried to access
  try {
  
  res.sendRedirect("/jsp/testing/Welcome.jsp");
  return;
  
  
  }
  catch (Exception ignored) { }

  // Couldn't redirect to the target.  Redirect to the site's home page.
  res.sendRedirect(req.getScheme() + "://" + 
   req.getServerName() + ":" + req.getServerPort());
}
  }

  protected boolean loggedIn(String name, String passwd) {
   
return (name=="abc"  passwd=="123 ");

  }
} 

//
//Here is the login.html

HTML
TITLELogin/TITLE
BODY
FORM ACTION=/servlet/LoginHandler METHOD=POST
CENTER
TABLE BORDER=0
TRTD COLSPAN=2
P ALIGN=CENTER
Welcome!  Please enter your NnnnNamebr
 and Password to log in.
/TD/TR

TRTD
P ALIGN=RIGHTBName:/B
/TD
TD
PINPUT TYPE=TEXT NAME="name" VLAUE="" SIZE=15
/TD/TR

TRTD
P ALIGN=RIGHTBPassword:/B
/TD
TD
PINPUT TYPE=PASSWORD NAME="passwd" VALUE="" SIZE=15
/TD/TR

TRTD COLSPAN=2
CENTER
INPUT TYPE=SUBMIT VALUE="  OK   "
/CENTER
/TD/TR
/TABLE
/BODY/HTML


//*
//Here is the Welcom.jsp


% if ( session.getValue("userName") == null) { %

B hello...it is a nullB

% // here we can give some error message %

% } else {%

 !--- so this is the authorized user let's display the welcome 
 message --- 

HTML

 HEAD

B Welcome  %= session.getValue("userName")%

/B

 /HEAD 

BODY

  !--- all the other stuff --

/BODY

/ HTML

%  }   %