• 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

Simple struts question - Use action to retrieve data from db

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a struts newb, so this might be quite easy. All the tutorials I've read or either more complex or they use the jsp itself to generate a list of data.

I want my action class to retrieve my data for me from the db and send in to the jsp page.

So far I've got this (which doesn't work ofcourse):
I wanna use the following method in my CustomerDAO.java:


My getAccountAction.java has:


And my struts-config has the following action mapping:


My simple jsp has:


So obviously I'm doing something wrong or forgetting something. Can anyone point me out what?
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How is what you have not working? Are you getting an error? What error are you getting?
 
Ritchie Warsi
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Allright, my tomcat error logging isn't configured well, so I'll give you what I get on screen. I'm rather unsure as to what action to call first (getAccountAction or accOptions - the first forwards to the second that calls on a jsp, this is where my data should be - sounds complicated but it's for Tiles).

When calling on getAccountAction i get:


And when calling on accOptions.do i get:


But is my approach correct?

[ December 20, 2004: Message edited by: Ritchie Warsi ]

[ December 20, 2004: Message edited by: Ritchie Warsi ]

[ December 20, 2004: Message edited by: Ritchie Warsi ]

[ December 21, 2004: Message edited by: Jason Menard ]
[ December 21, 2004: Message edited by: Jason Menard ]
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The general approach is fine, however your problem is in your DAO's method. The RuntimeException that you throw when you catch the HibernateException isn't halting the application flow, so when your JSP tries to execute, it can't find the customerList bean that it expects to be in request since your getCustomerList() method in the DAO never returned one. I'm not really that up on Hiberbate, so as to why exactly your DAO method doesn't work, you would be best having that question answered in the Object Relational Mapping forum.
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would also add that if you are having your DAOs throw RuntimeExceptions, then you would want to make sure that you set up Struts Exception Handling to deal with these. Otherwise, you probably shouldn't be throwing RuntimeExceptions.
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic