You have the syntax for passing objects correct, but I don't understand
the error you got.  I'm still kind of hacking to.

--Monte Glenn Gardner


On Wed, 23 Jan 2002, Means, Garann R. wrote:

> Monte,
>
> I'm only putting them in <%! %> tags because I get errors like this when I
> don't:
>
>         An error occurred between lines: 51 and 53 in the jsp file:
> /LabGenEdit.jsp
>
>         Generated servlet error:
>
> C:\Tomcat\jakarta-tomcat-4.0\work\localhost\HepC\LabGenEdit$jsp.java:121:
> Type    expected.
>           out.write("\r\n\t\r\n");
>                       ^
> Is there another way to approach it? (I'm just sort of hacking my way
> through this..)
>
> Also, what is the syntax for passing a request? Just:
>
>         someVar = brokenMethod(request);
>         ...
>         public int brokenMethod(HttpServletRequest request) { ... } ?
>
> Thanks for responding so quickly!
> Garann
>
> -----Original Message-----
> From: Gardner Monte [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 23, 2002 10:35 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Where to put methods for a jsp page?
>
>
> I may have misunderstood what you're asking, but let me give it a
> try.  If you are using the <%! %> syntax for declaring JSP methods, then
> you have to understand that those methods are seperat from the
> main method of your JSP page, which is actually the service() method
> of a servlet.  The request object is a local variable of the
> service method, and therefore does not exist in your other methods.
> If you want other methods to be able to access the request object, you
> have to pass the request object into the methods via parameters.
>
> --hope that helps.
>
> --Monte Glenn Gardner
>
>
> On Wed, 23 Jan 2002, Means, Garann R. wrote:
>
> > Hi,
> >
> > I'm converting a bunch of asp pages to jsp. The asp pages had methods
> > running on the server side, so I've left them there in the jsp. When I try
> > to compile the jsp, I get errors telling me the compiler doesn't know
> > "request.getParameter", but only within the methods. I'll post the code,
> and
> > maybe someone can give me feedback?
> >
> > <!-- top of page (there are some declarations up here, superfluous for
> these
> > methods) -->
> > <%! public String mkDate() {
> >                 String sHourHTML = "";
> >                 String sMinHTML = "";
> >                 String sHTML = "";
> >
> >                 sHTML  = "<select name='selCollHour'>";
> >
> >                 // ...
> >                 // ...
> >                 // ... this all compiles fine, and doesn't use
> > request.getParameter
> >
> >                 return sHTML;
> >         } %>
> >
> > <%!     public String redChem(String root) {
> >                 float usrIn = 0;
> >                 float lBnd = 0;
> >                 float uBnd = 0;
> >                 String sRed = "";
> >
> >                 // these next three lines are throwing the errors
> >                 usrIn = Float.parseFloat(request.getParameter("txtArea" +
> > root));
> >                 lBnd = Float.parseFloat(request.getParameter("hdnLowBnd" +
> > root));
> >                 uBnd = Float.parseFloat(request.getParameter("hdnUpBnd" +
> > root));
> >
> >                 if (usrIn != 0) {
> >                         if ((usrIn > uBnd) || (usrIn < lBnd)) {
> >                                 sRed = "style='color:red'";
> >                         }
> >                         else {
> >                                 sRed = "";
> >                         }
> >                 }
> >                 return sRed;
> >         } %>
> >
> >
> > Thanks,
> > Garann Rose Means
> > ITAS1
> > WA State Dept. of Corrections
> >
> >
> ===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> >  http://archives.java.sun.com/jsp-interest.html
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.jsp
> >  http://www.jguru.com/faq/index.jsp
> >  http://www.jspinsider.com
> >
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to