Hi Mick,
you should consider whether or not it should really be static
within the context of your application, or whether it should be
instantiated and held in the session or request, etc.
If you really want it to be static, then try:
<snip>
// should always uppercase first letter :)
public class ParkingPricehandler{
private static String thePrice;
public static void setPrice( String price ) {
thePrice = price;
}
public static String getPrice() {
return thePrice;
}
}
</snip>
since you included a constructor, it looks like you
are wanting it to be instantiated directly, which you can do
by either creating an instance of your class in a code snippet
or in a jsp tag and then reference the instance in your html:
<% parkingPriceHandler pph = new parkingPriceHandler();
pph.setPrice("200");
%>
...
<INPUT TYPE="TEXT" NAME="price" SIZE="0"
VALUE="<%=pph.getPrice()%>">
Cheers,
Jin
> -----Original Message-----
> From: Mick Sullivan [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, March 07, 2001 10:54 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Please Help On Static Reference ........
>
>
> Hi Jin
> Thanks for replying
> How do I actually do that? Im kinda new to JSP so bear with me here.
> I have done the following to the bean (made it static)
> package parkingPrice;
>
> public class parkingPricehandler{
>
> private static String thePrice;
>
> public parkingPricehandler() {
> //thePrice = null;
> }
>
> public void setPrice( String price ) {
> thePrice = price;
> }
>
> static public String getPrice() {
> return thePrice;
> }
>
> }
> but i still get the same error?
> Any ideads, thanks , Mick
>
>
> ----Original Message Follows----
> From: Byung Jin Chun <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: "'[EMAIL PROTECTED]'"
> <[EMAIL PROTECTED]>
> Subject: RE: Please Help On Static Reference ........
> Date: Wed, 7 Mar 2001 10:29:02 -0500
>
> You have to either make the method a static one,
> or instantiate an instance of your class to call
> the method.
>
> Jin
>
> > -----Original Message-----
> > From: Mick Sullivan [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, March 07, 2001 10:20 AM
> > To: [EMAIL PROTECTED]
> > Subject: RE: Please Help On Static Reference ........
> >
> >
> > It is a class, a very basic one at that
> > Here it is:
> >
> > package parkingPrice;
> >
> > public class parkingPricehandler{
> > private String thePrice;
> >
> > public parkingPricehandler() {
> > //thePrice = null;
> > }
> > public void setPrice( String price ) {
> > thePrice = price;
> > }
> > public String getPrice() {
> > return thePrice;
> > }
> > }
> >
> > Any ideas?
> >
> >
> > ----Original Message Follows----
> > From: "Samson, Lyndon [IT]" <[EMAIL PROTECTED]>
> > Reply-To: [EMAIL PROTECTED]
> > To: "'[EMAIL PROTECTED]'"
> > <[EMAIL PROTECTED]>
> > Subject: RE: Please Help On Static Reference ........
> > Date: Wed, 7 Mar 2001 14:57:58 -0000
> >
> > Is parkingPriceHandler an instantiated object or a class?
> >
> >
> > -----Original Message-----
> > From: Mick Sullivan [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, March 07, 2001 2:48 PM
> > To: [EMAIL PROTECTED]
> > Subject: Please Help On Static Reference ........
> >
> >
> > Hi all,
> > I was wondering could someoone please help me with this error
> > im getting.
> >
> > Im trying to output a value saved from a previous page in a
> > text box in a
> > new page using the JSP command:
> > <INPUT TYPE="TEXT" NAME="price" SIZE="0"
> > VALUE="<%=parkingPriceHandler.getPrice()%>">
> >
> > The function getPrice() is defined in parkingPriceHandler.
> > This is the error i get:
> > "Can't make static reference to method java.lang.String
> > getPrice() in class
> > parkingPrice.parkingPricehandler."
> >
> > Error: 500
> > Location: /project/jsp/view_parking_cost.jsp
> > Internal Servlet Error:
> >
> > org.apache.jasper.JasperException: Unable to compile class for
> > JSPC:\tomcat\work\localhost_8080%2Fproject\_0002fjsp_0002fview
> > _0005fparking_
> > 0005fcost_0002ejspview_0005fparking_0005fcost_jsp_30.java:94:
> > Can't make static reference to method java.lang.String
> > getPrice() in class
> > parkingPrice.parkingPricehandler.
> > out.print(parkingPricehandler.getPrice() );
> > ^
> > 1 error
> >
> > at org.apache.jasper.compiler.Compiler.compile(Compiler.java,
> > Compiled
> > Code)
> > at
> > org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java,
> > Compiled
> > Code)
> > at
> >
> org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java,
> > Compiled Code)
> > at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java,
> > Compiled
> > Code)
> > at
> > org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfN
> > ecessary(JspSe
> > rvlet.java,
> > Compiled Code)
> > at
> > org.apache.jasper.servlet.JspServlet$JspServletWrapper.service
> > (JspServlet.ja
> > va,
> > Compiled Code)
> > at
> >
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java,
> > Compiled Code)
> > at org.apache.jasper.servlet.JspServlet.service(JspServlet.java,
> > Compiled
> > Code)
> > at
> > javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled
> > Code)
> > at
> >
> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java,
> > Compiled Code)
> > at org.apache.tomcat.core.Handler.service(Handler.java, Compiled
> > Code)
> > at
> > org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java,
> > Compiled Code)
> > at
> > org.apache.tomcat.core.ContextManager.internalService(ContextM
> > anager.java,
> > Compiled Code)
> > at
> > org.apache.tomcat.core.ContextManager.service(ContextManager.java,
> > Compiled Code)
> > at
> > org.apache.tomcat.service.http.HttpConnectionHandler.processCo
> > nnection(HttpC
> > onnectionHandler.java,
> > Compiled Code)
> > at
> >
> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java,
> > Compiled Code)
> > at
> >
> org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java,
> > Compiled Code)
> > at java.lang.Thread.run(Thread.java, Compiled Code)
> >
> > Whats the Story with Static Referencing???
> > Please please help coz my project is due up very soon and Im
> > dead confused,
> > Thanks a million in advance.
> >
> >
> > ______________________________________________________________
> > ___________
> > Get Your Private, Free E-mail from MSN Hotmail at
> http://www.hotmail.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
>
> ______________________________________________________________
> ___________
> Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]