• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Invoking java layer from JSP

 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a parent JSP, lets say JSP-1 and a small jsp (JSP-2)which will be included in JSP 1.

Whenever jsp 1 is loaded I want jsp-2 to make a call to db and fetch the latest values. The real challenge is we don't have any buttons to use. The invocation should happen on the fly.

Can we do this without having java code in the jsp page?
 
Sheriff
Posts: 67645
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
That's not really a modern structure to follow. Rather the data access would not be triggered by the JSP, but by a controller servlet invoked before the JSP.

If you are interested in structuring you web app using best practices, this article may be of some use.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response.

I am using Struts in my application.

This is my requirement. I have couple of columns in a table where one is a key and another is a value. I need to show those values in those pages which are mapped to the key(different pages are identified by using the key).

I thought of using a generic JSP page and control the display with logic equal tags. But my problem is how to trigger the query to fetch the values in the included JSP page.

Is there a better design to this requirement.
 
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

I am using Struts in my application.



I'm going to move this to our Struts forum.
If you're using Struts, you should try to follow Stuts best practices.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I understand what you're trying to do, but it seems like you want to allow the user to make some selection and then have part of the page redisplay with new information. If this is true, I'd recommend one of the following options:

1 - Use an IFRAME for the changeable portion of the page. Then have the user action submit the page and specify the IFRAME name as the target. The Struts Action class would then retrieve information from the database and forward to a JSP which is then displayed in the IFRAME.

2- Use AJAX to make a call to the server without submitting the page and then use JavaScript and DOM to rebuild part of the page on the fly.
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic