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.

java.lang.NumberFormatException: For input string in JSP Page

The ${userRecords} here ${userRecords.user_first_name} ${userRecords.user_middle_name} is a List<User>, however you’re attempting to access it as if it’s a single User. This is not valid. In EL, a List can only be accessed with an integer index, indicating the position of the list item you’d like to access, like so ${userRecords[0].user_first_name} ${userRecords[0].user_middle_name} The exception is also … Read more

Convert base64 byte array to an image

What you get is just the toString output of an array. You need however the byte array converted to a String. You should create a method in bean public String getByteArrayString() { return new String(this.imageByteArray); } and reference this in your JSP. While technically you should define which encoding to use for an array of … Read more

Iterate ArrayList in JSP

It would be better to use a java.util.Map to store the key and values instead of two ArrayList, like: Map<String, String> foods = new HashMap<String, String>(); // here key stores the food codes // and values are that which will be visible to the user in the drop-down foods.put(“man”, “mango”); foods.put(“app”, “apple”); foods.put(“gra”, “grapes”); // … Read more

How does server prioritize which type of web.xml error page to use?

This is not specific to Tomcat. This is specific to the Servlet API. How the error page is determined is specified in chapter 9.9.2 of Servlet API specification 2.5. Here’s an extract of relevance: SRV.9.9.2 Error Pages If no error-page declaration containing an exception-type fits using the class-hierarchy match, and the exception thrown is a … Read more

Character encoding JSP -displayed wrong in JSP but not in URL: “á » á é » é”

Try to set URIEncoding in {jboss.server}/deploy/jboss-web.deployer/server.xml. Ex: <Connector port=”8080″ address=”${jboss.bind.address}” maxThreads=”250″ maxHttpHeaderSize=”8192″ emptySessionPath=”true” protocol=”HTTP/1.1″ enableLookups=”false” redirectPort=”8443″ acceptCount=”100″ connectionTimeout=”20000″ disableUploadTimeout=”true” URIEncoding=”UTF-8″ />

Not allowed to load local resource: file

For anyone landing here and working in asp.net: I was having the same issue (not allowed to load local resource) in every browser except IE. My workaround was to have the anchor direct to a handler & include a query string for the path: <a href=”https://stackoverflow.com/questions/25750742/handler.ashx?file=//server_name//dir//filename.pdf” /> Then the handler would write the file as … Read more

javax.servlet.ServletException: bean [name] not found within scope

You need the class attribute instead of the type attribute. The following: <jsp:useBean id=”bean” type=”com.example.Bean” scope=”request” /> does basically the following behind the scenes: Bean bean = (Bean) pageContext.getAttribute(“bean”, PageContext.REQUEST_SCOPE); if (bean == null) { throw new ServletException(“bean not found within scope”); } // Use bean … While the following: <jsp:useBean id=”bean” class=”com.example.Bean” scope=”request” /> … Read more