• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bean Undefined Exception in JSP

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

Let me tell the scenario.
I fill 6 items in a html form with action attribute going to a JSP page 'insertitems.jsp' which retrieves these items using request.getParameter(). These items are put in a HashMap.
I wrote a bean class 'mybean' with a set method setFields(HashMap) and a int getInsertedFlag(). In the class a Hashmap is its member variable.
The set method sets the hashmap sent by JSP to the beans hashmap.
The get method inserts the 6 items in database using JDBC and returns updation status.

'mybean' class has compiled and placed in a package.

The 'insertitems.jsp' uses usebean tag wth id="mybeanid" and then setproperty tag to set the hashmap.
Later using the beans id I call the get method in a scriplet like mybeanid.getinsertedFlag() instead of get property tag.
Here the Compiler gives error that the id is undefined.
'insertitems.jsp' hasnt got compiled as a result.
Cant I use beans id that way.

Please Comment.

Sandeep Deshmukh
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sandeep,
you can invoke the method in scriptlet instead of using the get property tag.why dont u post the code and the exception you are facing

-raj
 
Sandeep Deshmukh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys

Thanks to Rajendra for replying to my query.
Actually there was a typing error.
Still I had to compromise on 1 matter regarding useBean tag in JSP.
The param attribute in setProperty can only be from request parameters.
If I want to use my own variable in JSP page such as a HashMap to be passed param does not pass it to the bean.
value attribute can have constants as their value. How can I pass my own refernce objects in setProperty tag using either param or value attribute.

Please Comment.

Sandeep
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Rajendar said, you can do this from a scriptlet.


Ex:
<useBean id="myBean" class="pkg.myBean" scope="session" />
<% myBean.setMap(new HashMap()); %>
 
this llama doesn't want your drama, he just wants this tiny ad for his mama
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic