• 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

Dynamically rendering JSP page

 
Greenhorn
Posts: 10
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI All,

I have to render a JSP page based on a database table.

For example, there are two tables, one is having 2 columns and another is having 3 columns.

I will give one of the table name as input, based on this it should be able to render the next page. For the moment we can think all columns are having varchar2 datatype, so all fields should be rendered as text boxes.

Can you please suggest how to write JSP code for above requirement?
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Are you using servlet or any java based MVC framework for this application ?? Or directly rendering it on jsp via scriptlets ?

Kindly clarify please.

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it is a servlet, do the redirect conditionally.
 
sreekanth jella
Greenhorn
Posts: 10
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ujwal,

I have to use either Struts 2 or Spring framework. Currently I am trying with Struts 2.

and also I have tried this using scriptlets. Here is my sample code.


But this is not recommended, I want to use some helper class to retrieve the meta data from DB table, and pass this information to JSP. But I didnt see any way to do in struts 2.

Let me know if any other information is required.
 
Sheriff
Posts: 67745
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
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts 2 exposes data to JSPs through public getter methods: if you have a list (for example) of results of a DB query:

Then in the JSP:

Since you appear to be using scriptlets (almost always a Bad Idea) you could just put the list into request scope by either (a) implementing RequestAware (recommended) or (b) using the ServletActionContext utility class (not as testable).
 
sreekanth jella
Greenhorn
Posts: 10
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks David, It helped me.
 
I once met a man from Nantucket. He had a tiny ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic