Hi Srini:
I havent studied your code carefully, but thought would offer another solution
which is really simple and has worked well for me:
Step 1: in the login page, set a session variable, say "GoodUser" to, say,
"True".
Step 2: In the doPost, do the foll:
public void doPost(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException{
HttpSession thisSession = req.getSesion(false); //note: "false" is
important!
if(session == null) resp.sendRedirect(completePathTpLoginPage);
else {
String goodUser = (String)sesion.getValue("GoodUser");
if ((goodUser != null) && (goodUser.equalsIgnoreCase("True")){
//You're off to the races: do what you "normally" do for
doPost, this is a good user who has logged in..
}
else resp.sendRedirect(completePathTpLoginPage);
} //end doPost
You will need to do a similar thing in your doPost (to prevent folks from maybe
bookmarking your servlet URL and then accessing it directly.)
Hope this helps.
Geeta
"Srini Sathya." wrote:
> Hi all,
>
> I am trying to prevent any users callingmy servlet directly. All need to go
> thro the login page.
>
> I have tried in the dopost but it is not working. I have searched the
> archives too, but of no use. Can any1 point me whatis exactly wrong in this
> code. For the first time it is showing error eventhough i go thro a html
> page what is exactly going wrong in this one please help me.
>
> Thanks a million for ur help,
> Srini
>
> Code:
> ---
>
> public void doPost(HttpServletRequest req, HttpServletResponse res) throws
> ServletException, IOException{
>
> Connection locon_Conn = probj_DBMgr.getConnection("access");
> PrintWriter out = res.getWriter();
>
> HttpSession loobj_Session = req.getSession(true);
> loobj_Session.setMaxInactiveInterval(10);
> String lows_Sessionvalue =
> (String)loobj_Session.getValue("login");
>
> if (lows_Sessionvalue == null )
> {
> out.println("Sorry u session is expired u need to
> login again!!!");
> res.setHeader("Refresh", "5;
> URL=/jobtracking/login.htm");
>
> }
> String lows_Name = req.getParameter("Login");
> String lows_Password = req.getParameter("Password");
> String lows_UID = new GetIDS().getUID(lows_Name,
> locon_Conn, out);
> out.println("The name is " + lows_Name);
> out.println("The password is " + lows_Password);
> out.println("The uid is " + lows_UID);
> loobj_Session.putValue("uid", lows_UID);
> loobj_Session.putValue("login", lows_Name);
> }
>
> -----Original Message-----
> From: [Mariano Pollio] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 10, 2000 1:46 PM
> To: [EMAIL PROTECTED]
> Subject: Fw: odbc - date error
>
> Hi,
>
> the sintax is ... where xxx = CONVERT('1946-02-31','WE8HP','WE8DEC')
> .......
> ^ ^
> | |
> dest character sets and source
> character sets
>
> :-)
>
> ------------------------
> From: "Roy Silva (Java)" <[EMAIL PROTECTED]>
> Subject: odbc - date error
> Date: Mon, 10 Jul 2000 11:55:27 +0100
> To: [EMAIL PROTECTED]
>
> hi,
>
> I have a column (SQL Server 6) called dateofbirth - a SMALLDATETIME field.
> I am collecting a string (dateofbirth) from a servlet and passto a stored
> procedure to verify the dob. The dob format is '1946-02-31'
>
> where dateofbirth = convert(smalldatetime, dob)
> which returns the following error message.
>
> [Microsoft][ODBC SQL Server Driver][SQL Server] Syntax error converting
> SMALLDATETIME from character string.
>
> Please help.
> thanks
> roy
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ---------------End of Original Message-----------------
>
> --------------------------------------------------------
> Name: Pollio
> E-mail: [EMAIL PROTECTED]
> Date: 07/10/2000
> Time: 13:46:03
> --------------------------------------------------------
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html