• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Passing Static Array from JSP to Java Bean

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 75708
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question too difficult for “beginning”. Moving discussion.
 
Don't listen to Steve. Just read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic