struts2 file upload loosing parameters

Problem solved ! From the updated documentation, now the problem can be solved by using the new JakartaStreamMultiPartRequest : As from Struts version 2.3.18 a new implementation of MultiPartRequest was added – JakartaStreamMultiPartRequest. It can be used to handle large files, see WW-3025 for more details, but you can simple set <constant name=”struts.multipart.parser” value=”jakarta-stream” /> … Read more

Avoid duplicate submission of Struts 2 jsp page

If the goal is to prevent duplicate submission of forms then use token interceptor http://struts.apache.org/2.x/docs/token-interceptor.html or tokenSession interceptor http://struts.apache.org/2.x/docs/token-session-interceptor.html. If you simple want to refresh the page after submit without submitting again then redirect to action where you only show results not form. Use redirectAction result for that.

Problem with Json plugin in Struts 2

Yes it is possible, the solution requires the use of include/exclude parameters. Following is an example. Methods getJson1 and getJson2 show includeParameters while getJson3 shows excludeParameters. Note: Although the example uses strings as the arguments for include/exclude parameters the string is interpreted as a regular expression. So I could replace “string1, string2” on action3 with … Read more

How to forward request from servlet to action of struts2?

In order to do this you may also need to set the filter to run on FORWARD (and INCLUDE as your code shows, although you state you want a FORWARD): <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> <!– If you want includes as well –> </filter-mapping>

Populating one select menu based on another select menu using AJAX in Struts2

The same way you can do it in Struts2, but instead of servlet you can use the action. For example @Action(value=”/PopulateStateList”, results=@Result(type=”json”, params = {“contentType”, “application/json”, “root”, “map”})) public class AjaxMapAction extends ActionSupport { Long countryId; //getter and setter Map<String, String> map=new HashMap<String, String>(); public Map<String, String> getMap() { return map; } @Override public String … Read more

global results across different packages defined in struts configuration file

Define global result in the package that other packages extend. For example <package name=”default” extends=”struts-default”> … <global-results> <result name=”error”>/pages/error_page.jsp</result> </global-results> … </package> This result could be used across actions that forward to error page and as exception handling result. If you are using conventions plugin with annotations you could define @Results annotation on the class … Read more

how to compare list elements(type string) and string(in request scope) using struts 2 tags

With the IteratorStatus object: <s:iterator value=”lis” status=”ctr”> <s:property /> <s:if test=”%{#request.str.equals(lis[#ctr.index])}”> -> This value from “lis” is equal to the value of “str” </s:if> <br/> </s:iterator> With the var parameter: <s:iterator value=”lis” var=”currentValue”> <s:property /> <s:if test=”%{#request.str.equals(#currentValue)}”> -> This value from “lis” is equal to the value of “str” </s:if> <br/> </s:iterator> With the top … Read more