aspose file tools*
The moose likes Struts and the fly likes Dynamically rendering JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamically rendering JSP page" Watch "Dynamically rendering JSP page" New topic
Author

Dynamically rendering JSP page

sreekanth jella
Greenhorn

Joined: Aug 21, 2008
Posts: 10

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?

SCJP : 90%
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
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.


Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
If it is a servlet, do the redirect conditionally.
sreekanth jella
Greenhorn

Joined: Aug 21, 2008
Posts: 10

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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61238
    
  66

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Aug 21, 2008
Posts: 10

Thanks David, It helped me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically rendering JSP page