Jason Berk

Ranch Hand
+ Follow
since May 03, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jason Berk

anybody here use WSAD 5.1.2 w/ struts? I'm pulling my hair out with WSAD's inability to recompile JSP files when I change them. I have an index.jsp with this code:

<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<logic:forward name="showForm"/>

in my struts-config I have:
<global-forwards>
<forward name="showForm" path="myApp.form" />
</global-forwards>

but when I surf to the index.jsp, I get this error:

javax.servlet.jsp.JspException:
Cannot find global ActionForward for name form
at
org.apache.struts.taglib.logic.ForwardTag.doEndTag(ForwardTag.java:92)
at
org.apache.jsp._index._jspService(_index.java:86)
blah...blah...blah....

I ran a search just to be sure...and the word "form" never even appears in source code ANYWHERE in the project. WSAD doesn't have the "clean" feature that Eclipse does, so how the hell do I get WSAD to use the latest index.jsp?

Jason
15 years ago
why is it when the validator sees an invalid date it pukes a stack trace in the log? From the view, everything behaved as expected...but I'd hate to think everytime some user entered a bad date we'd get this massive stack trace in the log.

Jason


org.apache.commons.validator.GenericTypeValidator 02/40/1977
org.apache.commons.validator.GenericTypeValidator
TRAS0014I: The following exception was logged:
java.text.ParseException: Unparseable date: "02/40/1977"
at java.text.DateFormat.parse(DateFormat.java:345)
at ...
at ...
stack trace here
at ...
at ...
16 years ago
hello all,

Looking for how others have enforced site navigation. I have a relatively small web app with the following "views" (jsp):

1) identifyUser (has radio to select staff or customer)
2) verifyStaff
3) verifyCustomer
4) verifyCustomerExtended
5) confirmRequest
6) requestSuccessful

A user MUST follow one of the following paths of navigation:
1 - 2 - 5 - 6 OR 1 - 3 - 4 - 5 - 6

each page expects you to have completed the previous page.

I'm trying to set up our environment here at work to be reusable and that's
where things get sticky. Let's say I have three WARs (apps) all using struts. Each app specifies it's request processor as:

foo.bar.App1.App1RequestProcessor
foo.bar.App2.App2RequestProcessor
foo.bar.App3.App3RequestProcessor

All of which extend...

foo.bar.shared.processor.SharedTilesRequestProcessor (which extends TilesRequestProcessor) a fourth project.

My SharedTilesRequestProcessor looks like so:

//this is so children can use the preprocess method
protected abstract void getPreprocessHook(HttpServletRequest request, HttpServletResponse response)throws ServletException;

//this is so individual apps can provide navigation rules to the
//application independant check navigation method declared here
protected abstract Object getNavRules()throws Exception;

protected boolean processPreprocess
(HttpServletRequest request, HttpServletResponse response) {
boolean continueProcessing = true;
String appName = "NAME NOT SET";
try{
HttpSession session = request.getSession();
MessageResources resources = (MessageResources)
request.getAttribute(Globals.MESSAGES_KEY);
appName = resources.getMessage("APPLICATION.VIEWABLE.NAME");
session.setAttribute("APPLICATION_NAME", appName);
//add checkNavigation(request, response, getNavRules())
getPreprocessHook(request, response);
} catch (Exception e) {
continueProcessing = false;
logger.error(appName + ": Exception Caught during Preprocessing");
logger.error(appName + ": " + e.getMessage(), e);
try {
request.getSession().setAttribute("errorMessage", null);
request.getRequestDispatcher("/WEB-INF/error.jsp").
forward(request,response);
} catch (Exception ee) {
logger.error(appName + ": forwarding error - "
+ ee.getMessage(), ee);
}
}
return continueProcessing;
}

I'd like to add a "checkNavigation" method (commented in code) to this class (along with any other needed helper methods).

Is this even possible?

Seems to me the work of enforcing navigation can be abstracted to one location. Given requested URI "x" and application state "y", you either succeed or fail (maybe even throw a custom "IllegalNavigationException"). Seems silly that each WAR would have to reinvent the wheel regarding navigation enforcement. Each app should only have to provide the structures (be it hashmaps, xml, etc) which define what state the app must be in for a received request to be worthy of (further) processing.

this idea is a modification of the recipe I read in the "Struts Recipes" book by Franciscus & Gurovich. I like their solution but I would like to abstract it "up a level" so any WAR which provides a "state/request ruleset" can benifet from it

Have I lost my mind here? How are others accomplishing this? Is there YAF (Yet another framework) I should be using.

I've been reading about Tapestry, Velocity, Spring (with and without struts), and wondered if they might be my answer.

I'm beginning to wonder if maybe I'm missing one of the points of struts....seems the framework would rather you rebuild the wheel each application, but will help you rebuild the wheel identically to the way you built it last time....does that even make sense?

Thanks for any input,

jason

[ June 27, 2006: Message edited by: Jason Berk ]

[ June 27, 2006: Message edited by: Jason Berk ]
[ June 27, 2006: Message edited by: Jason Berk ]
16 years ago
yeah, that's how I have it now. Is that really the ONLY way? Can I atleast specify the path as a variable...like pull it in from the resource bundle?

Jason...
16 years ago
the struts-config for MyAppA has an action with a forward like so:

<forward name="quit" path="/apps/account/tools" redirect="true"/>

The URL that gets built is:

http://server/apps/account/MyAppA/apps/account/tools

and I get a 404

what I want is: http://server/apps/account/tools/ (which is a different WAR)

How can I pull something like that off?

Jason
16 years ago
the struts-config for MyAppA has an action with a forward like so:

<forward name="quit" path="/apps/account/tools" redirect="true"/>

The URL that gets built is:

http://server/apps/account/MyAppA/apps/account/tools

and I get a 404

what I want is: http://server/apps/account/tools/ (which is a different WAR)

How can I pull something like that off?

Jason
16 years ago
so is there any difference between Action Chaining (frowned on by Struts documentation) and PRG (Post-Redirect-Get) design.

I'm thinking of using that design to disallow back button from error pages and I don't see a difference between the two. Am I missing something?

Jason
16 years ago
is it possible to access my message resource bundle from the processPreprocess method?
16 years ago
Merrill,

http://jakarta.apache.org/commons/logging/troubleshooting.html


Some containers use a custom LogFactory implementation to adapt JCL to their particular logging system. This has some important consequences for the deployment of applications using JCL within these containers.

Containers known to use this mechanism:
* WebSphere Application Server from IBM (versions 5 and 6).


If you want to continue to use the default container mechanism then:
* Find and replace the commons-logging implementation used by the container with the most modern release
(NOT POSSIBLE FOR BUSINESS REASONS)

* Replace the commons-logging jar in the application with the commons-logging-adapters jar. This will ensure that application classloader will delegate to it's parent when loading LogFactory.
(WORKED LIKE A CHAMP)


only hitch is that we had to rename "commons-logging-adapters.jar" to
"commons-logging.jar" to match the struts.jar manifest.

Now I have WARs using struts 1.2.9 running on WAS5.1

jason
16 years ago
has anyone gotten WAS 5.1 + Struts 1.2.9 working together?

I'm getting bit (I think) by WAS's forced loading of the commons-logging.jar:

Caused by: org.apache.commons.logging.LogConfigurationException:
The chosen LogFactory implementation does not extend LogFactory.
Please check your configuration.
(Caused by java.lang.ClassCastException:
com.ibm.ws.commons.logging.TrLogFactory)
at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:574)

I fear this older version of WAS has a different version of the commons-logging.jar that struts 1.2.9 was built against.

I have the log4J jar in the EAR also. Is there some way I can tell the commons-logging used inside the WAS container (that I have no control over?) to use a specified LOG4J factory.

Jason


Caused by: org.apache.commons.logging.LogConfigurationException: The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. (Caused by java.lang.ClassCastException: com.ibm.ws.commons.logging.TrLogFactory)
at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:574)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:517)
at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:308)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at at org.apache.struts.util.MessageResources.<clinit>(MessageResources.java:57).null(Unknown Source)
... 40 more
Caused by: java.lang.ClassCastException: com.ibm.ws.commons.logging.TrLogFactory
at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:531)
[ June 19, 2006: Message edited by: Jason Berk ]
16 years ago
Merrill...

thanks...I was afraid of that. If I understand you correctly (regarding struts out of the box), if I want to have each application be its own WAR, then every WAR will have to contain a copy of the standard definition files, the standard tiles, and the standard layouts.

That means if we change our footer content, we'd have to update the footer in every WAR that used it.

I don't like putting everyting into one WAR cause (if I understand WSAD's session context) each application in the WAR would be sharing the same session and that could lead to naming collisions which would be a real PITA to debug.

On the other hand, having all the layouts, definitions, tiles copied into each new webapp doesn't sound very scalable either.

How is the rest of the world (you?) handling this. Are other just using one WAR with multiple "apps"? Is this something that people have just come to except and hope their header/footer don't change often...and when they do change the IDE makes updating them easier?

I wish I could "extend" JSPs. I want a master jsp with includes to the header/footer content and children JSPs that fill in the page content.

I want to have my cake and eat it too...:-)
16 years ago
Would it be possible to do something like this:

1) place all the content common to all applications in one "Common" WAR.
- common tiles like header and footer
- common tile definitions
- images
- css
- javascript files

Then in each application war, reference the tile definitions in the common war. I assume I could specify in each application war's struts config file the absolute path to the common war tile definitions files.

In the end, what I'd like is a StrutsTemplate WAR that all applications start from. In this template I could set up the struts config and define the "standard" file structure. This template would have tile/image/etc references back to the Common war described above.

I'm going down this road because I like the idea of having each application being its own WAR. You get an http session object only available to your app and adding/removing an app from production is as simple as adding/removing it from the EAR. Problem is I have a slew of content that I want all applications to be able to use, but only have the content exist in one place. Solutions are obvious when it comes to images and truly static HTML....like run apache for those things. Solution gets a bit stickier when you consider tiles. I don't want every application to have a copy of the standard tile definitions or layouts or the tiles themselves. I'd like to have all that content defined in a Common.war and let each individual app use it. Is it even possible to do something like this? Can appA's struts config reference the tile definition in appB?

Jason Berk
[ June 16, 2006: Message edited by: Jason Berk ]
16 years ago
Merrill,

funny, that's exactly what I did and it worked just fine. Now however, my group and I have decided to go a different direction. Instead of each WAR we create having to have all the images/stylesheets/javascripts/shared JSPs we created a SharedContent WAR that is struts enabled. The only action is a forward like so:

<action path="/logout" forward="/WEB-INF/logout.jsp" />

in the webcontent area there is a logout.jsp with a logic:redirect to "logout.do"

The idea is that all future WARs will be built from a "BaseWAR" so that all WARs have a similar design.

in each WAR this IBM magical logout form will be provided and won't need to be changed:

<form method="post" action="ibm_security_logout" name="logout">
<input type="submit" name="logout" value="Logout">
<input type="hidden" name="logoutExitPage"
value="<SharedContent:path />/logout.jsp">
</form>

I created a custome tag SharedContent that ends up producing this:
https://some.server.com/context/root/SharedContent

(This also allows me to do:
<img src="<SharedContent:path />/images/my_image.jpg">)

problem is struts seems to be doing something to the URL. When I click the logout button, I get a 404 and the URL reads:

https://my.server.com/context/root/MyApp/context/root/SharedContent

is this a situation where I should have the logout form point to an action declared in the local struts config file which then redirects to a JSP in a completely different WAR?

curious,

Jason
16 years ago
my shop uses WAS5 currently and I have struts + tiles running as desired. I have a tile named "logout" that has the magical IBM logout form:

<form method="post" action="ibm_security_logout" name="logout">
<input type="submit" name="logout" value="Logout">
<input type="hidden" name="logoutExitPage" value="<%=logoutURL%>">
</form>

I would like the logoutURL I specify to use tiles like all the other pages...is that possible? The form isn't processed by struts, so how do I set this up?

Jason
16 years ago