• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing Static Array from JSP to Java Bean  RSS feed

 
Tony McManus
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is for a class. After searching through many forums, I know that this isn't "ideal", but it is the assignment.

That said, I'm trying to pass an array from JSP to a Java Bean. When I call the Java Bean method from my JSP, the error it throws says "Cannot make a static reference to the non-static method setItems(String[]) from the type CatalogPage" (and another error for the title).

I understand that something has to be added to the java in order to accept the static info from the JSP, I'm just stuck on exactly how to do that. Any/all help is appreciated!

PhonePage.jsp


CatalogPage.java:
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it a bean or a servlet? It shouldn't be both. What's the resins for trying to make it a servlet?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In any case, if you want to call methods from a static context, they need to be static themselves.
 
Tony McManus
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a bean, not a servlet. I'm not 'trying' to make it a servlet. The assignment was to convert a servlet into beans & jsps.

I know that I need to call methods from a static context. My point is: how do I do that? I need to take the values from the PhonePage.jsp and pass them to the CatalogPage.class. I know there probably has to be a way to define a method to do this, i just can't figure out how (and that's after 4 days of google searching, so clearly I'm either doing it wrong or I'm searching for the wrong stuff).
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it it's a bean it shouldn't be abstract or static in the first place, it should not extend HttpServlet, and shouldn't have any doXXX methods.

First step is to remove the servlet-ness from the class, make it non-abstract, and make sure it follows the bean pattern.

Next step, you'd instantiate an instance of the bean and you won;t have any static context to begin with.
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question too difficult for “beginning”. Moving discussion.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!