• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Why my action class in not executing?

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This is my struts-configfilecode
<action
attribute="fileuploadanddownloadForm"
input="/FileUploadandDownload.jsp"
name="fileuploadanddownloadForm"
path="/fileuploadanddownload"
scope="request"
type="com.ochre.ewash.hfodetails.web.form.FileUploadandDownloadAction">
<forward name="success" path="/FileUploadandDownload.jsp"></forward>
</action>




this is my action class
package com.ochre.ewash.hfodetails.web.action;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.apache.commons.*;
import org.apache.struts.upload.FormFile;
//import org.apache.commons.fileupload.FileItemFactory;

import java.io.*;
import java.util.*;

import com.ochre.ewash.hfodetails.web.form.*;
import com.ochre.ewash.hfodetails.viewhelper.*;





import org.apache.struts.upload.FormFile;
/**
* @author
*/

/**
* Struts File Upload Action Form.
*
*/
public class FileUploadandDownloadAction extends Action {
private static Logger LOG = Logger .getLogger(FileUploadandDownloadAction.class);
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
LOG.info("Inside Action");
FileUploadandDownloadForm myForm = (FileUploadandDownloadForm)form;
// Process the FormFile
FormFile myFile = myForm.getTheFile();
String contentType = myFile.getContentType();
String fileName = myFile.getFileName();
int fileSize = myFile.getFileSize();
byte[] fileData = myFile.getFileData();
System.out.println("contentType: " + contentType);
System.out.println("File Name: " + fileName);
System.out.println("File Size: " + fileSize);

return mapping.findForward("success");
}
}




Please reply as soon as possible.

Thanks in advance..
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Please reoply as soon as possible.


Please EaseUp.

And take some time to UseCodeTags to make all this code more readable.
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you please show your FileUploadandDownload.jsp file to us.
use code tag properly.

Regards,
Sriram.V
 
Priyanka Das
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
fdf
 
Ranch Hand
Posts: 84
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please check the action class path in struts-config.xml and action class package are different.

In struts-config.xml,


In action class,
 
Yes, my master! Here is the tiny ad you asked for:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic