You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by teh j <to...@yahoo.com.au> on 2001/04/10 04:21:26 UTC

static reference to a method

Hi there
I was wondering if anybody could help me out with
something?

I have a JSP that is trying to access a method in a
java class that I have defined. However, when I try
and run the pgae, it gives the 500 error message and
says

"Can't make static reference to method
java.lang.String getSelected(java.lang.String,
java.lang.String) in class
dynamicContent.dynamicContent."
 
I have not declared the method as static nor the
class. 

The method is part of an error handling page (called
retry.jsp) that is shown to the user when they have
entered data incorrectly in a form. Its function is to
preselect an option (by returing the word SELECTED) in
a HTML select box (the one that the user entered in
the first place) by comparing the value that was
entered by the user in the original input form to the
value of the select box options as they are created
(they are dynamically created, not HTML coded).       
       

_____________________________________________________________________________
http://movies.yahoo.com.au - Yahoo! Movies
- Now showing: Dude Where's My Car, The Wedding Planner, Traffic..

Re: static reference to a method

Posted by "Felix A. Milovanov" <fe...@terasystems.com>.
> 
> Hi there
> I was wondering if anybody could help me out with
> something?
> 
> I have a JSP that is trying to access a method in a
> java class that I have defined. However, when I try
> and run the pgae, it gives the 500 error message and
> says
> 
> "Can't make static reference to method
> java.lang.String getSelected(java.lang.String,
> java.lang.String) in class
> dynamicContent.dynamicContent."
> 
> I have not declared the method as static nor the
> class.
> 
> The method is part of an error handling page (called
> retry.jsp) that is shown to the user when they have
> entered data incorrectly in a form. Its function is to
> preselect an option (by returing the word SELECTED) in
> a HTML select box (the one that the user entered in
> the first place) by comparing the value that was
> entered by the user in the original input form to the
> value of the select box options as they are created
> (they are dynamically created, not HTML coded).
> 
  Hello,

  i'm not a great expert in Java, but I think the problem is
you try to use some method of class not defined like static
while you do not have an instance of this class. Try to create
it or define method like static :)))

  Sincerely,
						Felix.

RE: static reference to a method

Posted by CPC Livelink Admin <cp...@fitzpatrick.cc>.
The problem is that you have not declared the method as static.  So you need
to either do this :

(new dynamicContent.dynamicContent()).getSelected("A", "B");

or declare the function as static String getSelected(string a, String b) and
call

dynamicContent.dynamicContent.getSelected("A", "B");

If the function is not declared static, then you have to have an object of
the class to call the function.

-----Original Message-----
From: teh j [mailto:tomcat_list2000@yahoo.com.au]
Sent: Monday, April 09, 2001 10:21 PM
To: tomcat-user@jakarta.apache.org
Subject: static reference to a method


Hi there
I was wondering if anybody could help me out with
something?

I have a JSP that is trying to access a method in a
java class that I have defined. However, when I try
and run the pgae, it gives the 500 error message and
says

"Can't make static reference to method
java.lang.String getSelected(java.lang.String,
java.lang.String) in class
dynamicContent.dynamicContent."

I have not declared the method as static nor the
class.

The method is part of an error handling page (called
retry.jsp) that is shown to the user when they have
entered data incorrectly in a form. Its function is to
preselect an option (by returing the word SELECTED) in
a HTML select box (the one that the user entered in
the first place) by comparing the value that was
entered by the user in the original input form to the
value of the select box options as they are created
(they are dynamically created, not HTML coded).


____________________________________________________________________________
_
http://movies.yahoo.com.au - Yahoo! Movies
- Now showing: Dude Where's My Car, The Wedding Planner, Traffic..