You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gregor Rayman <gr...@gmx.net> on 2001/07/24 16:59:46 UTC

Initializing Application Scope Attributes & *.do in

Hi, perhaps these are FAQ:

1) 

My application has menu structure configurable in the database. I want 
to read the structure from the database when the app starts and store
it in an application scoped bean.

To be able to read the data, I need a DataSource so I need access to
actionServlet. What is the best way to do this? I know, I can use my own
servlet inherited form ActionServlet - but is there any ohter, perhaps
more configurable way?


2) 

When I need initiazed data in my application, I usually put the
initialization into setServlet of the action which needs the data
and I thought never to need to access such data from a JSP directly.

But now I've found this problem when creating menus. 

I've created a MenuForm which holds the information about the
current location "id" and a collection of menu's children. 
MenuAction reads the id and fills the children collection, checking
whether the current user should see the menu items.
menu.jsp then displays the menu structure from MenuForm.

It works perfectly, till I try to put this menu into another JSP
via <jsp:include ...> or <template:put content="/menu.do?id=100">

The problem is that my MenuAction does not produce the HTML, it 
*forwards* it to the menu.jsp. And forwardning seems to be forbidden
inside an include.
(Err: Cannot forward as OutputStream or Writer has already been obtained)


Is there a way, how to include a *.do generated page which internally
uses forward?

(Actually, this could be probable solved with the workflows. The action
actually does not have to forward to the jsp. I just need to let it perform
and include the jsp then)

--
gR