Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

struts alternative to ...

Status
Not open for further replies.

orlyotero

Programmer
Jun 2, 2005
21
US
Hello folks,
I posted this thread in java sun, and still waiting "any" response(actually still waiting any response for any of my questions), but, anyway:

During my free time I'm in the process of re-writing a web app I coded in the near past.
It's an online magazine builder, basically, this tool uses a database to store the articles being edited before they are ready for production. Once the whole bunch of articles are ready for the public, a kind of routine DB 2 XML is called and generates a XML version of this current magazine issue, then another routine is called(kind of XML 2 HTML, using SAX) and generates the whole .jsp version(paged version, printer friendly version and table of contents with all related links between them) of the entire magazine issue. Then another routine is called in order to transform the XML <article> element in pdf version using jakarta fop.
Now, I decided to produce static .jsp version of the articles to release the DB Server from serve static contents since once the articles are done, it is very unprobable that they will change, anyway if the articles changes, they could be generated again to any version. But it will be uncommon from fix articles every week, so this way the response time would be a lot lesser than read the articles from DB.
While using struts I have found a limitation in order to achieve this goal, and it is related to the following policy:
1) Not all articles are public for all users These means that I'm using struts action mapping roles to tell the my custom struts processor to avoid unauthorized user from read article "x".
The point is that I can use the same approach I used in the old version: process the "policy" in jsp file, but this is not a MVC approach, this is not a struts approach. BUT what alternative or solution does Struts can give? I mean, since a lot of jsp files are created, they are in a "hidden" directory, they can only be accessed through Struts actions, but since the files are new, how can I set up the struts's configuration "structure" at runtime and without restarting the server, and serializing the configuration structure?
It would be pretty nice that a dinamocally created .jsp could be associated to an action mapping and an action class.
Any suggestion, ideas, discussion, proposal?
Regards,
OO

P.S. Sorry about my english
 
Hello,
For those dealing with a similar situation:

a servlet filter could be used, struts doesn't includes but role based authorization, when needed to add .jsp files dinamically a pattern action and filter could be used.

Regards,
OO
 
struts DOES have role-based authorization (roles attribute)at the action mapping level. look at the user guide again. the filter will help with authentication mostly. finer grain authorizations (buttons, links, page components etc.) will require your own custom solution (e.g custom tag or utility method that map roles to resource).
 
Hello mythaeus,
I know struts has role-based authorization, actually I'm using it, but my problem comes when my application generates .jsp files as a result of a xml transformation.
In order to make them work as a normal struts application, the transformation will need to generate .class code for the action classes as well as update struts-config.xml with the new action mappings, ahhh, and reload the mapping files and the .class files without terminating users sessions. Non-practical solution.

What I wrote was a filter.
This way a generic entry in the mapping element points to a forward action, the corresponding .jsp file just includes the "id" input parameter, for instance:

<action path="/article" type="com.orly_otero.struts.Actions.ForwardAction" parameter="/article.page" input="/unexpected-error.page" name="articleNoForm" validate="true" scope="request" />


<filter>
<filter-name>Logged Subscribers Articles</filter-name>
<filter-class>com.orly_otero.filters.struts.LoggedSubscribersOnly</filter-class>
...
<filter-mapping>
<filter-name>Logged Subscribers Articles</filter-name>
<url-pattern>/article.do</url-pattern>
</filter-mapping>
...

article.jsp:
<jsp:include page='<%= "/WEB-INF/pages/issues/"+request.getParameter("id")+".jsp" %>'/>


Application genereates files at:
.../issues/2005/vol1-iss1/article_1.jsp
....
.../issues/2005/vol1-iss1/subscribers/article_n.jsp


and the filter takes care of the "subscribers" pattern, redirecting to login page if not logged.(filter get executed before request processor instance)

regards,
OO

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top