This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

using modules with JSPs behind web-inf

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using struts 1.2.9 which the struts site claims is the "prime time"
ready version.

I would like to use modules and put my JSPs behind WEB-INF to protect them. When I try this with struts, it rewrites my URL with the module name and causes 404 errors on validation failures.

I read all over the net that I need to change my forwardPattern & pagePattern in my controller to "/WEB-INF/$M$P", but again, the struts site docs explicitly state that anything other then $$, $M and $P are "silently swallowed". (http://struts.apache.org/struts-doc-1.2.9/userGuide/configuration.html)

currently, my input param is:
input="/WEB-INF/struts/modules/FOOModule/jsp/foo.jsp"

I want coworkers to be able to have input params like:
input="/WEB-INF/struts/modules/BARModule/jsp/bar.jsp"

developing in WSAD 5.1.2
will deploy to WAS 5

The default struts config is empty, and I want to keep it that way. Our existing WAR has numerous non-struts servlets. I have added the needed lines to web.xml to use the struts controller. The idea is future development would be in struts, but we don't want to mess with existing code right now. We would like to see all new development occurr in "WEB-INF/struts/modules/YOU_MODULE_NAME" with two subdirectories: "CONFIG" and "JSP". Your module's struts config goes into CONFIG and your module's JSPs go into JSP. That way, every developer can work independantly of any other developer.

Been trying to get this to work for almost two weeks now. I'm beginning to wonder if it's even possible.

Any help appreciated.

Jason
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jason,

Give us an example of:

* One of your Action mappings (the <action> tag in struts-config.xml)
* The URL that Struts is actually returning when validation fails on that action.
[ May 15, 2006: Message edited by: Merrill Higginson ]
 
Jason Berk
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill and Company.

using struts 1.2.9
(cause struts.apache.org says it's the production ready version)

I have the following files:
/WebContent/MyApp/index.jsp
/WEB-INF/struts/modules/MyApp/config/struts-config.xml
/WEB-INF/struts/modules/MyApp/jsp/IdentifyCustomer.jsp
/WEB-INF/struts/modules/MyApp/jsp/VerifyCustomer.jsp
/WEB-INF/struts/modules/MyApp/jsp/VerifyEmployee.jsp
/WEB-INF/struts-config.xml (has NO entries)
/WEB-INF/web.xml

web.xml has:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>config/MyApp</param-name>
<param-value>WEB-INF/struts/modules/MyApp/ (split for readability)
config/struts-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<taglib>
//normal tablibs bean/html/logic/nested/tiles
</taglib>


index.jsp contains:
<logic:redirect action="/MyApp/CollectInfo.do"/>


struts config contains:
<action path="/CollectInfo"parameter="/WEB-INF/struts/modules/MyApp/jsp/IdentifyCustomer.jsp"
type="org.apache.struts.actions.ForwardAction"/>


IdentifyCustomer.jsp has a form tag:
<html:form action="/ProcessIdentity" method="post">


Then again in my struts config I have:
<action path="/ProcessIdentity"
type="MyApp.actions.ProcessIdentity"
name="IdentifyCustomerForm"
validate="true"
input="/WEB-INF/struts/modules/MyApp/jsp/IdentifyCustomer.jsp" >
<forward
name="verifyEmployee"
path="/WEB-INF/struts/modules/MyApp/jsp/VerifyEmployee.jsp"/>
<forward
name="verifyStaff"
path="/WEB-INF/struts/modules/MyApp/jsp/VerifyCustomer.jsp" />
</action>


My Problem:

when I submit an incomplete IdentifyCustomer.jsp page the validator sees the failure it tries to send me back to:

' input="/WEB-INF/struts/modules/MyApp/jsp/IdentifyCustomer.jsp" '

so I can complete the form. Problem is instead of seeing the form with previously entered data, I get a 404 error in my browser:

Error 404: /MyApp/WEB-INF/struts/modules/MyApp/jsp/IdentifyCustomer.jsp

Notice the interjection of "MyApp" before WEB-INF. This is wrong.

How does struts send users back to the input page...is it a forward?

How can I fix this problem,

Jason Berk
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this:

In your struts-config.xml file, specify:

<controller inputForward="true" />

This tells the controller that whenever you specify an input, you'll be specifying a forward, rather than an actual URI.

Then in your ProcessIdentity Action, create a new forward:

<forward
name="backToCustomer"
path="/WEB-INF/struts/modules/MyApp/jsp/IdentifyCustomer.jsp"/>

and in your <action> tag:

<action path="/ProcessIdentity"
type="MyApp.actions.ProcessIdentity"
name="IdentifyCustomerForm"
validate="true"
input="backToCustomer" >
 
Jason Berk
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merrill. I actually stumbled onto that solution myself after my post. Is it me or is the documentation for struts "a mess". I would still like to know where all these websites came up with the idea of setting the forward/page Pattern to "/WEB-INF/$M$P". I find NOTHING on the struts site that leads me to believe that's ever been possible. It's difficult enough to wrap your head around struts alone....the last thing we need is false documentation.

Jason
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

the struts site docs explicitly state that anything other then $$, $M and $P are "silently swallowed"


I have not used this feature, but I am interpreting the documentation differently that you are. Here is the statement:

$x - (Where "x" is any character not defined above) Silently swallowed, reserved for future use.


This seems to be saying that $M, $P and $$ all have special meanings but that if I enter $A or $X that will be ignored. I do not read this to mean that I cannot put a constant string such as "WEB-INF" on the front. Oh well...it sounds like you got it working for you.

- Brent
 
Jason Berk
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
using a DTD validator, if I set either field to something other then $M $P $$ or $X I get the following warning:

Pattern should consist [of] any combination of the following: "$M" "$P" "$$" "$x"

and since $x doesn't do anything and I can't imagine who would use $$, that only leaves $m and $p

Jason
 
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic