I am new to struts. I am wondering what input variable here signifies. After some googling, the only conclusive piece of info was this:
Input: The physical page (or another ActionMapping) to which control should be forwarded when validation errors exist in the form bean.
Is there any other use for the input parameter besides the case of an error occurring?
<action
roles="somerole"
path="some/path"
type="some.java.class"
name="somename"
input="someInput"
scope="request"
validate="false"
parameter="action">
<forward name="success" path="some/path"/>
<forward name="download" path="/another/path"/>
</action>
Yes, although you're correct that it's primarily a forward for failed validation.
The input has a dedicated method to return it: ActionMapping.getInputForward(). This can be used in custom (Java-based) validation to return to the input page.
It can also be used to identify a "landing" page: an action base class or custom request processor might send GET requests to the input forward, and process POSTs normally.
Related
<sec:http auto-config="false" use-expressions="true" pattern="/**"
authentication-manager-ref="authenticationManager" entry-point-ref="authenticationEntryPoint">
<sec:custom-filter ref="myFilter" position="BASIC_AUTH_FILTER" />
<sec:intercept-url pattern="/**" access="permitAll" />
</sec:http>
HI,
What I'm trying to do seems like it would be so simple, yet i've been trying to figure out how to do it for hours. Hopefully someone can help.
I simply want to create an authentication filter that will intercept all incoming requests, do some processing, then pass it on to the next filter in the chain.
When I try and do that using a pttern of /, I keep getting that error "A universal match pattern ('/') is defined before other patterns in the filter chain, causing them to be ignored. Please check the ordering in your namespace or FilterChainProxy bean configuration" even though i've tried all kinds of things, like guaranteeing my filter is the very last one listed in the security.xml file. I've even attempted to specify the order with a filterChainProxy definition like this:
<beans:bean id="filterChainProxy"
class="org.springframework.security.web.FilterChainProxy">
<sec:filter-chain-map>
<sec:filter-chain pattern="/**"
filters="<filterlist, with mine being the very last!>" />
</sec:filter-chain-map>
</beans:bean>
Nothing seemed to work, despite spending hours researching and googling to try and figure that out, so I gave up, and created an entry in the web.xml file for my filter. Finally, I hit a breakpoint in the filter, so I knew it was getting invoked. But then the problem I ran into was, nothing was getting injected by Spring, I'm assuming because I went "outside the framework", and, I can't even pull the authenticated user, I get a Spring error saying i'm not authenticated, yet other filters defined inside the security.xml can pull it just fine.
I'm not sure what to do here; very suprised something so simply is so difficult.
Please advise, thanks
I'm using ColdFusion 10's new REST API. At one of the endpoints, I'm returning a file like this:
<cffunction name="getFil"
access="remote"
httpmethod="GET"
restpath="{id}/fil"
returntype="void">
<cfargument name="id" required="true" restargsource="path" type="numeric" />
<cfprocessingdirective suppresswhitespace="no">
<cfheader name="Content-Disposition" value="attachment; filename=foo.pdf" />
<cfheader name="Content-Type" value="application/pdf">
<cfcontent file="C:/some_path_to_file/foo.pdf" deletefile="no" />
</cfprocessingdirective>
</cffunction>
It works perfectly and responds with 200 OK, following by the file in the response body. Even though the response is fine, the site-wide error handler gets called and the error message looks like this:
[coldfusion.runtime.AbortException : null] null <br>The error occurred on line 124.
The client never sees the error, but my email service sends out a notification email to the developers when the site-wide error handler is called. Anyone know what this AbortException is and how to prevent it?
I suspect it's the case that some CFML tags which halt processing (like <cfcontent> in this case) seem to use the <cfabort> code to do so. I can't rememeber how to repro it now, but <cfabort> does raise an exception under the hood (and and AbortException sounds about right), but ColdFusion for the most part suppresses it. REST requests don't use the same servlet as normal CF requests, so perhaps it's less good at suppressing it?
If you (for testing purposes, temporarily) remove the <cfcontent>, I would expect the exception to not occur.
I feel I've been a bit vague with some of the detail here, but I'm not in the position to give it a thorough test just now. Sorry about that. When I find time I'll try to firm things up and sound more definite about it.
I cannot argue with Adam's answer as it seems to make sense. Perhaps just catching that specific error (if you can) and suppressing the emails will suffice for you. But I did a little searching and possibly found a different approach you could try. Instead of using <cfheader> and <cfcontent> tags just return the actual binary data for the PDF from your service. See this blog article about it:
CF html to pdf service - consume from node.js using rest api
Don't worry about the node.js reference as the given example does not use it. They just link to a node.js example as well.
In their example they are passing the data to the service but it should be trivial for you to instead read your PDF file and return that data.
I've been playing with Spring integration, and I can't see how best to solve the following problem.
Say I have XML messages arriving onto a channel. These messages may have arbitrary structure, and I want to convert them to my canonical form, so I think I want to write custom converters for each type of structure, so that I can do whatever processing and error-checking I want.
The obvious thing is to wire up a router to have a look at the messages and route to an appropriate converter, but I think this means I need to hard-code the processing flow onto a channel pointing at each converter.
I'd like to avoid hard-configuring in the different converters and routing logic, and the alternative that springs to mind is to have a set of converters that implement some kind of boolean canHandle(message), so that we just show the message to each converter until one 'claims' the message or we run out. This way, it seems like I might be able to annotate the converters into the configuration without actually modifying the processing flow.
I'm new to Spring integration and I may well be mis-thinking this. Is there a stock way to do this in Spring integration, have I missed something or am I going about it all wrong?
There are a number of ways to do this. The first one that came to mind is a recipient list router with selector expressions:
<recipient-list-router id="simpleDynamicRouter" input-channel="simpleDynamicInput">
<recipient selector-expression="#handler1.canHandle(payload)" channel="toHandler1"/>
<recipient selector-expression="#handler2.canHandle(payload)" channel="toHandler2"/>
<recipient selector-expression="#handler3.canHandle(payload)" channel="toHandler3"/>
</recipient-list-router>
<transformer ... ref="handler1" />
<transformer ... ref="handler2" />
<transformer ... ref="handler3" />
Where handler1 etc are <bean/>s with your implementation, and canHandle() method.
Another option is to write your own custom dynamic router; there's an example of how to do that here https://github.com/SpringSource/spring-integration-samples/tree/master/advanced/dynamic-ftp
for example
<global-forwards>
<forward name="welcome" path="/Welcome.do"/>
</global-forwards>
<action-mappings>
<action path="/Welcome" forward="/welcomeStruts.jsp"/>
</action-mappings>
My question is:
When client requests Welcome.do page, the global forward will map the /welcome.do page with the name attribute "welcome". Then in action-mapping it will map between the name in forward tag with the path in action tag so it will know that it should forward to the welcomeStruts.jsp file.
Am I correct?
If not, how can it determine the correct mapping between user's request *.do to the corresponding jsp file?
Thank you
You're not correct. When a request comes in, Struts tries to map the URL or the request with the path of an action. Forwards are not used at this stage.
When the action returns a forward name, Struts first looks for a forward with this name in the forwards of the action, and if not found, it looks in the global forwards.
How can I use common forward for all actions. I mean I don't want to write common forward in all actions.
<forward name="invalidlogin" path="/invalidlogin.jsp" />
I don't want to write this in all <Actions>.
It sounds like you're just describing a global forward. Global forwards are defined in the struts-config.xml file. That way, the forward is defined for all actions so any action can use the forward.
So you would place something like the following in your struts-config.xml file:
<global-forwards>
<forward name="error" path="jsp/error.jsp"/>
</global-forwards>
Then just forward to "error" in your action class:
return mapping.findForward("error");