This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

galne vaibhav

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

Recent posts by galne vaibhav

Hi SWAPNIL please try this simple example you need ony one html one jsp and jxl jar

12 years ago

i have code in which i have grid an elements in which element gets deleted on checkbox sharing the same

by using this way you can send the values is id

12 years ago

you are making mistake you mention alloewed type as image/jpeg and trying to upload image/jpg

just open the file in paint save as .jpeg format and try to upload

12 years ago
what you have to do is just get the value data from database put in hashmap or list and show on jsp in list attribute as mention below

JSP code:where objBussCode is my hashmap name

Edited by Dave to be legible.
12 years ago

you can do simple thing write onclick javascript function and assign value to hidden control and in action class write the getter setters for hidden control.

12 years ago

hi you have to follow simple steps

functions gfnDisableKeys() and gfnDisableControls() are optional that is written for not allow any char other than date

action code

reply if your prblem not rsolved

take care of this things:
NOTE-you need to specify head tag like this i gusss your problem resolve when you do this


and you need to add struts2-dojo-plugin-2.1.6.jar to your application.

12 years ago
you only have to follow struts way of doing it you have call the setter method of the textfield
for example
my field name:
private String txtDescription;

getter and setters
public String getTxtDescription() {
return txtDescription;
public void setTxtDescription(String txtDescription) {
this.txtDescription = txtDescription;

In targeted method

place one line


reply if you want more detail.
12 years ago

Ben sassi mohammed wrote:hello
i have problem white struts 2 validator

Tags <s:fielderror> you told me works well. Except that
Now I have duplicate messages (I thought the message "by
Default "no longer present).

please looks attchments

thank you in advance

hi Ben sassi mohammed,

can you share your validation xml code and action code then it will be more clear i think you have done both xml action level validation also check for duplication of fielderror tag and actionerror tag.
12 years ago

Hi i have face the same problem and sorted out here is the solution:

Struts2 reads the file prepare tmp file and delete the tmp file after execute method

jsp code

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<%@taglib uri="/struts-tags" prefix="s" %>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<s:head />
<s:form action="fileUpload" method="post" enctype="multipart/form-data" >
<s:file name="userImage" label="User Image" />
<s:submit />

Action Class



import com.opensymphony.xwork2.ActionSupport;

public class FileUploadAction extends ActionSupport{

* Added serial version id
private static final long serialVersionUID = -5138905699893319423L;

private File userImage;

private String userImageContentType;

private String userImageFileName;

private File upload;//The actual file
private String uploadContentType; //The content type of the file
private String uploadFileName; //The uploaded file name
private String fileCaption;//The caption of the file entered by user

public String execute() throws Exception {


String fullFileName = "/opt/glassfish/domains/domain1/logs/myFile.txt;
File theFile = new File(fullFileName);

FileUtils.copyFile(userImage, theFile);

} catch (Exception e) {



return SUCCESS;

public String getFileCaption() {
return fileCaption;
public void setFileCaption(String fileCaption) {
this.fileCaption = fileCaption;
public File getUpload() {
return upload;
public void setUpload(File upload) {
this.upload = upload;
public String getUploadContentType() {
return uploadContentType;
public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
public String getUploadFileName() {
return uploadFileName;
public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;

public File getUserImage() {
return userImage;

public void setUserImage(File userImage) {
this.userImage = userImage;

public String getUserImageContentType() {
return userImageContentType;

public void setUserImageContentType(String userImageContentType) {
this.userImageContentType = userImageContentType;

public String getUserImageFileName() {
return userImageFileName;

public void setUserImageFileName(String userImageFileName) {
this.userImageFileName = userImageFileName;


struts xml

"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

<package name="fileUploadPackage" extends="struts-default">
<interceptor-stack name="fileUploadStack">
<interceptor-ref name="exception" />
<interceptor-ref name="alias" />
<interceptor-ref name="servletConfig" />
<interceptor-ref name="prepare" />
<interceptor-ref name="i18n" />
<interceptor-ref name="chain" />
<interceptor-ref name="debugging" />
<interceptor-ref name="profiling" />
<interceptor-ref name="scopedModelDriven" />
<interceptor-ref name="modelDriven" />
<interceptor-ref name="fileUpload">
<param name="maximumSize">10240</param>
<param name="allowedTypes">image/jpeg,image/gif,image/png</param>
<interceptor-ref name="checkbox" />
<interceptor-ref name="staticParams" />
<interceptor-ref name="actionMappingParams" />
<interceptor-ref name="params">
<param name="excludeParams">dojo\..*,^struts\..*</param>
<interceptor-ref name="conversionError" />
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel,browse</param>
<interceptor-ref name="workflow">
<param name="excludeMethods">input,back,cancel,browse</param>

<action name="fileUpload" class="vaannila.FileUploadAction">
<result name="input">/index.jsp</result>
<result name="success">/success.jsp</result>

best of luck.

12 years ago