Hi, i have been trying to post emails on this list but getting
mailerdeamon replies that only subscribers can post. i dont know what happened
there....so i subscribed my other email address....
ok now for the topic at hand,
Wesly, udac is a public class which exists in the same package and login is a
static function. I think that much is pretty obvious. I had proper naming
conventions but when i moved my source code to linux, my
entire files names were
changed to lower case, and the application could not find the classes and jsp
files. i didnt know any other way(and didnt have any time for RnD) so i changed
the names of classes and jsp files to lower. any ways, my original topic is
sessions mix up, do you see any relevance of sessions in udac class? sessions
are getting created in loginmanager.
-----Original Message-----
From: Wesley Acheson [mailto:wesley.ache...@gmail.com]
Sent: Friday, August 20, 2010 2:05 AM
To: Tomcat Users List
Subject: Re: Sessions mix-up on Tomcat 6.0.26 on Linux
Maybe its just be but I still don't see where uadc is declared or even
imported.
On Thu, Aug 19, 2010 at 10:26 PM, Yawar Saeed Khan/ITG/Karachi <
yawar.sa...@mcb.com.pk> wrote:
> yea I did attach a .java file, anyways I am posting the code here;
>
> package org.mcb.services;
> import java.io.IOException;
> import java.io.PrintWriter;
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import javax.servlet.http.HttpSession;
> /**
> *
> * @author yawar.saeed
> */
> public class loginmanager extends HttpServlet {
>
> protected void processRequest(HttpServletRequest request,
> HttpServletResponse response)
> throws ServletException, IOException {
> response.setContentType("text/html;charset=iso-8859-1");
> PrintWriter out = response.getWriter();
> try {
> userbean user = new userbean();
> user.setUserId(request.getParameter("txt_userid"));
> user.setPassword(request.getParameter("txt_pass"));
> user = udac.login(user);
> if (user.isValid()){
> HttpSession session = request.getSession(true);
> session.setAttribute("user_id",user.getUserId());
> session.setAttribute("user_name",user.getName());
> session.setAttribute("role_id",user.getRole());
> session.setAttribute("role_desc", user.getRoleDesc());
> session.setAttribute("last_login", user.getLastLogin());
> //response.sendRedirect("main.jsp"); //logged-in page
>
> response.sendRedirect(response.encodeRedirectURL("main.jsp"));
> }else{
> // response.sendRedirect("index.jsp?user="+user.isValid());
> //revert back to login page
>
>
>response.sendRedirect(response.encodeRedirectURL("index.jsp?user="+user.isValid()));
>
> //revert back to login page
> }
> } finally {
> out.close();
> }
> }
> @Override
> protected void doGet(HttpServletRequest request, HttpServletResponse
> response)
> throws ServletException, IOException {
> processRequest(request, response);
> }
> @Override
> protected void doPost(HttpServletRequest request, HttpServletResponse
> response)
> throws ServletException, IOException {
> processRequest(request, response);
> }
> }
>
>
> ________________________________
>
> From: Wesley Acheson [mailto:wesley.ache...@gmail.com]
> Sent: Fri 20-Aug-10 1:56 AM
> To: Tomcat Users List
> Subject: Re: Sessions mix-up on Tomcat 6.0.26 on Linux
>
>
>
> Sorry can't see it. Are you sure you attached it? you could use something
> like pastebin if the mail list does accept attachments
>
>
> On Thu, Aug 19, 2010 at 9:27 PM, Yawar Saeed Khan/ITG/Karachi <
> yawar.sa...@mcb.com.pk> wrote:
>
> > source code is attached;
> >
> > suggestions are welcome.
> >
> > ________________________________
> >
> > From: Wesley Acheson [mailto:wesley.ache...@gmail.com]
> > Sent: Fri 20-Aug-10 12:38 AM
> > To: Tomcat Users List
> > Subject: Re: Sessions mix-up on Tomcat 6.0.26 on Linux
> >
> >
> >
> > Okay I've a little tehory could you post the entire code for
> loginmanager.
> >
> > How is udac declared? If its a class variable then *ITS NOT THREAD
> SAFE*.
> > As a basic rule don't declare class variables in a servlet (There are
> > exceptions to this rule but you shouldn't under normal circumstances)