You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by James Bigler <ja...@intellimedia.com> on 2000/02/05 21:06:18 UTC

getParameter

I just joined this list today so if this has already been discussed then

I apologize.

I running Tomcat 3.0 on NT 4.0 inside of Visual Age for Java 3.0.  (whew

had to get that out of the way).

I am having trouble with the getParameter method on the
HttpServletResponse object. I have an html form that I am posting to a
servlet.  Inside the servlet I am calling getParameter on the response
object and then doing some stuff.  Then I am using the request
dispatcher and forwarding the response and request objects back to a
jsp.

Basically the getParameter works fine in the servlet but will always
return null in the jsp.  I have found that if I don't call getParameter
in the servlet and then forward it immediately back to the jsp, the
getParameter will show my values.  It only breaks after getParameter is
called in the servlet.  I am enclosing some code snippets for the none
believers.

doPost of my servlet
public void doPost(HttpServletRequest request, HttpServletResponse
response)
 {
  try {
   HttpSession session = request.getSession(true);

   String pType = request.getParameter("type");  //comment out this line

and it works
   RequestDispatcher rd =
this.getServletContext().getRequestDispatcher("/login/showparms.jsp");
   rd.forward(request,response);
  } catch(Exception exception) {
  }
 }

simple jsp that shows form variables
<%@ page import="java.util.*" %>

<H3>Form Parameters</H3>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<%
  Enumeration ep = request.getParameterNames();
  while (ep.hasMoreElements()) {
      String name = (String) ep.nextElement();
      String[] values =
        request.getParameterValues(name);
      if (values != null) {
        for (int i = 0; i < values.length; i++) {
            String value = values[i];
%>
<TR><TD><%= name %></TD> <TD><%= value %></TD></TR> <%
        }
      }
  }
%>
</TABLE>

--
"Business Engine selects Intellimedia to build online business."
http://www.intellimedia.com/press/20000104.html

James Bigler
Software Engineer
Direct Dial: 404-760-8163




Re: getParameter

Posted by Marc Mandt <mm...@intellimedia.com>.
LOL

James Bigler wrote:

> You are right 3.1 does fix the getParameter method on the Response object but it
> breaks the getAttribute on the Session object(putValue and getValue work though).
> :(
>
> Michael Tildahl wrote:
>
> > This is a bug that is fixed in the 3.1M1 version.  It is also fairly easy to
> > fix in the 3.0 version if you do a little digging around, which is what I did.
> >
> > James Bigler wrote:
> > >
> > > I just joined this list today so if this has already been discussed then
> > >
> > > I apologize.
> > >
> > > I running Tomcat 3.0 on NT 4.0 inside of Visual Age for Java 3.0.  (whew
> > >
> > > had to get that out of the way).
> > >
> > > I am having trouble with the getParameter method on the
> > > HttpServletResponse object. I have an html form that I am posting to a
> > > servlet.  Inside the servlet I am calling getParameter on the response
> > > object and then doing some stuff.  Then I am using the request
> > > dispatcher and forwarding the response and request objects back to a
> > > jsp.
> > >
> > > Basically the getParameter works fine in the servlet but will always
> > > return null in the jsp.  I have found that if I don't call getParameter
> > > in the servlet and then forward it immediately back to the jsp, the
> > > getParameter will show my values.  It only breaks after getParameter is
> > > called in the servlet.  I am enclosing some code snippets for the none
> > > believers.
> > >
> > > doPost of my servlet
> > > public void doPost(HttpServletRequest request, HttpServletResponse
> > > response)
> > >  {
> > >   try {
> > >    HttpSession session = request.getSession(true);
> > >
> > >    String pType = request.getParameter("type");  //comment out this line
> > >
> > > and it works
> > >    RequestDispatcher rd =
> > > this.getServletContext().getRequestDispatcher("/login/showparms.jsp");
> > >    rd.forward(request,response);
> > >   } catch(Exception exception) {
> > >   }
> > >  }
> > >
> > > simple jsp that shows form variables
> > > <%@ page import="java.util.*" %>
> > >
> > > <H3>Form Parameters</H3>
> > > <TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
> > > <%
> > >   Enumeration ep = request.getParameterNames();
> > >   while (ep.hasMoreElements()) {
> > >       String name = (String) ep.nextElement();
> > >       String[] values =
> > >         request.getParameterValues(name);
> > >       if (values != null) {
> > >         for (int i = 0; i < values.length; i++) {
> > >             String value = values[i];
> > > %>
> > > <TR><TD><%= name %></TD> <TD><%= value %></TD></TR> <%
> > >         }
> > >       }
> > >   }
> > > %>
> > > </TABLE>
> > >
> > > --
> > > "Business Engine selects Intellimedia to build online business."
> > > http://www.intellimedia.com/press/20000104.html
> > >
> > > James Bigler
> > > Software Engineer
> > > Direct Dial: 404-760-8163
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> >
> > --
> > Michael Tildahl
> > VP of Technology
> > liveMetro.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
> --
> "Business Engine selects Intellimedia to build online business."
> http://www.intellimedia.com/press/20000104.html
>
> James Bigler
> Software Engineer
> Direct Dial: 404-760-8163
>
> We put the Internet to work.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: getParameter

Posted by James Bigler <ja...@intellimedia.com>.
You are right 3.1 does fix the getParameter method on the Response object but it
breaks the getAttribute on the Session object(putValue and getValue work though).
:(

Michael Tildahl wrote:

> This is a bug that is fixed in the 3.1M1 version.  It is also fairly easy to
> fix in the 3.0 version if you do a little digging around, which is what I did.
>
> James Bigler wrote:
> >
> > I just joined this list today so if this has already been discussed then
> >
> > I apologize.
> >
> > I running Tomcat 3.0 on NT 4.0 inside of Visual Age for Java 3.0.  (whew
> >
> > had to get that out of the way).
> >
> > I am having trouble with the getParameter method on the
> > HttpServletResponse object. I have an html form that I am posting to a
> > servlet.  Inside the servlet I am calling getParameter on the response
> > object and then doing some stuff.  Then I am using the request
> > dispatcher and forwarding the response and request objects back to a
> > jsp.
> >
> > Basically the getParameter works fine in the servlet but will always
> > return null in the jsp.  I have found that if I don't call getParameter
> > in the servlet and then forward it immediately back to the jsp, the
> > getParameter will show my values.  It only breaks after getParameter is
> > called in the servlet.  I am enclosing some code snippets for the none
> > believers.
> >
> > doPost of my servlet
> > public void doPost(HttpServletRequest request, HttpServletResponse
> > response)
> >  {
> >   try {
> >    HttpSession session = request.getSession(true);
> >
> >    String pType = request.getParameter("type");  //comment out this line
> >
> > and it works
> >    RequestDispatcher rd =
> > this.getServletContext().getRequestDispatcher("/login/showparms.jsp");
> >    rd.forward(request,response);
> >   } catch(Exception exception) {
> >   }
> >  }
> >
> > simple jsp that shows form variables
> > <%@ page import="java.util.*" %>
> >
> > <H3>Form Parameters</H3>
> > <TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
> > <%
> >   Enumeration ep = request.getParameterNames();
> >   while (ep.hasMoreElements()) {
> >       String name = (String) ep.nextElement();
> >       String[] values =
> >         request.getParameterValues(name);
> >       if (values != null) {
> >         for (int i = 0; i < values.length; i++) {
> >             String value = values[i];
> > %>
> > <TR><TD><%= name %></TD> <TD><%= value %></TD></TR> <%
> >         }
> >       }
> >   }
> > %>
> > </TABLE>
> >
> > --
> > "Business Engine selects Intellimedia to build online business."
> > http://www.intellimedia.com/press/20000104.html
> >
> > James Bigler
> > Software Engineer
> > Direct Dial: 404-760-8163
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
> --
> Michael Tildahl
> VP of Technology
> liveMetro.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

--
"Business Engine selects Intellimedia to build online business."
http://www.intellimedia.com/press/20000104.html

James Bigler
Software Engineer
Direct Dial: 404-760-8163

We put the Internet to work.



Re: getParameter

Posted by Michael Tildahl <mi...@livemetro.com>.
This is a bug that is fixed in the 3.1M1 version.  It is also fairly easy to
fix in the 3.0 version if you do a little digging around, which is what I did.



James Bigler wrote:
> 
> I just joined this list today so if this has already been discussed then
> 
> I apologize.
> 
> I running Tomcat 3.0 on NT 4.0 inside of Visual Age for Java 3.0.  (whew
> 
> had to get that out of the way).
> 
> I am having trouble with the getParameter method on the
> HttpServletResponse object. I have an html form that I am posting to a
> servlet.  Inside the servlet I am calling getParameter on the response
> object and then doing some stuff.  Then I am using the request
> dispatcher and forwarding the response and request objects back to a
> jsp.
> 
> Basically the getParameter works fine in the servlet but will always
> return null in the jsp.  I have found that if I don't call getParameter
> in the servlet and then forward it immediately back to the jsp, the
> getParameter will show my values.  It only breaks after getParameter is
> called in the servlet.  I am enclosing some code snippets for the none
> believers.
> 
> doPost of my servlet
> public void doPost(HttpServletRequest request, HttpServletResponse
> response)
>  {
>   try {
>    HttpSession session = request.getSession(true);
> 
>    String pType = request.getParameter("type");  //comment out this line
> 
> and it works
>    RequestDispatcher rd =
> this.getServletContext().getRequestDispatcher("/login/showparms.jsp");
>    rd.forward(request,response);
>   } catch(Exception exception) {
>   }
>  }
> 
> simple jsp that shows form variables
> <%@ page import="java.util.*" %>
> 
> <H3>Form Parameters</H3>
> <TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
> <%
>   Enumeration ep = request.getParameterNames();
>   while (ep.hasMoreElements()) {
>       String name = (String) ep.nextElement();
>       String[] values =
>         request.getParameterValues(name);
>       if (values != null) {
>         for (int i = 0; i < values.length; i++) {
>             String value = values[i];
> %>
> <TR><TD><%= name %></TD> <TD><%= value %></TD></TR> <%
>         }
>       }
>   }
> %>
> </TABLE>
> 
> --
> "Business Engine selects Intellimedia to build online business."
> http://www.intellimedia.com/press/20000104.html
> 
> James Bigler
> Software Engineer
> Direct Dial: 404-760-8163
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

-- 
Michael Tildahl
VP of Technology
liveMetro.com