users@glassfish.java.net

Re: Servlet is not passing value to JSP, it passes 0 instead of the real value

From: Wolfram Rittmeyer <w.rittmeyer_at_jsptutorial.org>
Date: Sun, 03 Feb 2008 17:27:24 +0100

glassfish_at_javadesktop.org wrote:
> I have written the following code, but still variable value is coming zero.
>
> Servlet calls JSP,and passes the value to JSP
>
> JSP code:
>
> String dialogidString= request.getParameter("dialogId");
> if(dialogidString == null){
> dialogidString = (String)request.getAttribute("dialogId");
> }
> int dialogid= new Integer(dialogidString).intValue();
>
>
> Servlet code:
> RequestDispatcher rd = null;
> request.setAttribute("dialogId", dialogId);
> rd=request.getRequestDispatcher("/jsp/tagDialog.jsp?dialogId="+dialogId);
> rd.forward(request,response);
>
> Also I tried,this in Servlet:
>
> RequestDispatcher rd = null;
> request.setAttribute("dialogId", dialogId);
> rd=request.getRequestDispatcher("/jsp/tagDialog.jsp");
>
> Still it passes 0 only & as per my prg, dialogId is more than 0,and this value is correct in Servlet

Hi shopperswing,

I think it would be best, if you could post a war-file together with a
description of how to reproduce your problem and the sources for the
servlet in question. From what you have said above the only thing that I
can think of is that the user send a request containing a dialogId with
a value of "0". In that case the request.getParameter-query would cause
your JSP to get a result of "0".


Regards,

Wolfram




> [Message sent by forum member 'shopperswing' (shopperswing)]
>
> http://forums.java.net/jive/thread.jspa?messageID=257145
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>