Hey Srini;
I think that's the same problem that javascript does on the history.go(-1)
method, If you are inserting something into database it works fine but while
selecting the null value gets a pointer value when redirected to the page it
refers to. It's something like a cookie but not really :)) call it a virtual
virtual cookie for the GetIDS() method you use,;;

So try the "" character to enable it for multiple times...

"Srini Sathya." wrote:

> Hi all,
>
> I got a real strange problem indeed.  Please have a look on the snip of code
> below
>
> <snip>
> String lows_UID = new GetIDS().getUID(lows_ParmName, locon_Conn, out);
> out.println("nuyllll" +lows_UID);
>
> if ( lows_UID == null ){
>         out.println("Please enter the correct username, Redirecting again to
> login page");
>         res.setHeader("Refresh", "4; URL=/jobtracking/login.htm");
> }
> </snip>
>
> I am determining whether the lows_UID is null and if yes i am redirecting to
> some login page again.
>
> This works fine.  But my problem is that it only works for 2 instances, if i
> enter wrong user name for the first 2 times it is redirecting correctly to
> the login page.  If i enter the username wrongly for the 3rd time it is
> throwing a nullpointer exception.  I tested this with putting the whole code
> under the try and catch block.  I really cant understand why it is working
> for 2 instances only.
>
> I tested whether the 3rd time it is calling the GET unforutnately it doesnt.
>
> Can any1 shed some light on this one??
>
> Thanks
> Srini
>
> PS:  I tried the checking of null with all possible combinations viz.,
> lows_UID.equalsIgnoreCase(null)
> lows_UID.equals(null)
> lows_UID.equalsIgnoreCase("null")
>
> -----Original Message-----
> From: Geeta Ramani [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 24, 2000 5:05 PM
> To: [EMAIL PROTECTED]
> Subject: Test Code for RequestDispatcher
>
> Hi folks;
>
> As it turns out, i *have* already posted the code to the list serve, but I
> think
> it may have been missed because i had replied to a post which had no
> subject.
> Since there seems to be some interest in this, i am posting this again;
> apologies in advance for the repost. Here goes:
>
> ////////////////////////////////////////////////////////////////////////////
> ////////////////////////////////
>
> Code for RDTest.html:
> ////////////////////////////////////////////////////////////////////////////
> ///////////////////////////////
>
> <HTML>
> <BODY>
> <FORM ACTION="/servlet/TestReqDispatcher" METHOD="POST">
> <CENTER>Testing Request Dispatcher Object</CENTER>
> <INPUT TYPE="TEXT" NAME="name" VALUE="Geeta">
> <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Try this!">
> </FORM>
> </BODY>
> </HTML>
> ////////////////////////////////////////////////////////////////////////////
> /////////////////////////////
>
> Code for SecondServlet.java:
> ////////////////////////////////////////////////////////////////////////////
> ////////////////////////////
>
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class SecondServlet extends HttpServlet
> {
>  public String getServletInfo()
>  {
>   return "Testing the way a request dispatcher works: this is the forwarded
> servlet.";
>  }
>
>  public void doGet(HttpServletRequest req, HttpServletResponse resp)
>  throws ServletException, IOException
>  {
>   System.out.println("In doGet of SecondServlet..");
>   resp.setContentType("text/html");
>   PrintWriter out = new PrintWriter(resp.getOutputStream());
>
>   // to do: code goes here.
>
>   out.println("<HTML>");
>   out.println("<HEAD><TITLE>TestReqDispatcher Output</TITLE></HEAD>");
>   out.println("<BODY>");
>
>   out.println("In doGet of SecondServlet<P>");
>   if (req.getParameter("name") != null)
>       out.println("Name parameter is " + req.getParameter("name"));
>   else out.println("Use queryString var if you want a param value with a
> Get!");
>
>   out.println("</BODY>");
>   out.println("</HTML>");
>   out.close();
>
>  }
>
>  public void doPost(HttpServletRequest req, HttpServletResponse resp)
>  throws ServletException, IOException
>  {
>      System.out.println("In doPost of SecondServlet..");
>   resp.setContentType("text/html");
>   PrintWriter out = new PrintWriter(resp.getOutputStream());
>
>   // to do: code goes here.
>
>   out.println("<HTML>");
>   out.println("<HEAD><TITLE>TestReqDispatcher Output</TITLE></HEAD>");
>   out.println("<BODY>");
>
>   out.println("In doPost of SecondServlet..<P>");
>         out.println("Val of name parameter is " + req.getParameter("name"));
>   out.println("</BODY>");
>   out.println("</HTML>");
>   out.close();
>  }
>
> }
> ////////////////////////////////////////////////////////////////////////////
> ///////////////////////////////////
>
> Code for TestReqDispatcher.java:
> ////////////////////////////////////////////////////////////////////////////
> ///////////////////////////////////
>
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class TestReqDispatcher extends HttpServlet
> {
>  public String getServletInfo()
>  {
>   return "Testing the way a request dispatcher works.";
>  }
>
>  public void doGet(HttpServletRequest req, HttpServletResponse resp)
>  throws ServletException, IOException
>  {
>   System.out.println("In doGet..");
>   ServletContext sc = this.getServletContext();
>   if (sc == null) System.out.println("Cannot get servlet context!");
>   else {
>       System.out.println("Just got servlet context..");
>       try{
>           RequestDispatcher rd =
> sc.getRequestDispatcher("/servlet/SecondServlet");
>           if (rd == null) System.out.println("Cannot get requst
> dispatcher!");
>           else {
>               System.out.println("Request dispatcher is non null.. Going to
> forward.");
>               rd.forward(req, resp);
>           }
>       }
>       catch(Exception e){
>           e.printStackTrace();
>           System.out.println("In TestReqDispatcher.." + e);
>       }
>
>   }
>  }
>
>  public void doPost(HttpServletRequest req, HttpServletResponse resp)
>  throws ServletException, IOException
>  {
>   System.out.println("In doPost of First Servlet..");
>   ServletContext sc = this.getServletContext();
>   if (sc == null) System.out.println("Cannot get servlet context!");
>   else {
>       System.out.println("Just got servlet context..");
>       try{
>           RequestDispatcher rd =
> sc.getRequestDispatcher("/servlet/SecondServlet");
>           if (rd == null) System.out.println("Cannot get requst
> dispatcher!");
>           else {
>               System.out.println("Request dispatcher is non null.. Going to
> forward.");
>               rd.forward(req, resp);
>           }
>       }
>       catch(Exception e){
>           e.printStackTrace();
>           System.out.println("In TestReqDispatcher.." + e);
>       }
>
>   }
>  }
>
> }
> ////////////////////////////////////////////////////////////////////////////
> //////////////////////
>
> At the risk of stating the obvious, here are some "notes":
>
> After compiling, setting the classpath and other such boring details, bring
> up
> the RDTest.html, and submit it. The first servlet's doPost will be executed,
> which will result in the second servlet's doPost being executed, and the
> value
> of the "name" parameter will be displayed. On the other hand, call
> TestReqDispatcher directly via a url (something like:
>
>  http://www.myServer.com/servlet/TestReqDispatcher
>
> as well as a url with a querystring var with name "name" as in:
>
> http://www.myServer.com/servlet/TestReqDispatcher?name=Cedric
>
> In both cases, the doGet of the first servlet will be executed, which will
> result in the doGet SecondServlet being executed.
>
> Hope this helps,
> Geeta
>
> ___________________________________________________________________________
> 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

Reply via email to