No action instance for path

No action instance for path

<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>


        <html:html locale="true">

        <head>

        <title>Struts File Upload and Save Example</title>

        <html:base/>

        </head>

        <body bgcolor="white">

        <html:form action="/FileUploadAndSave" method="post" enctype="multipart/form-data">

        <table>

        <tr>

          <td align="center" colspan="2">

                        <font size="4">File Upload on Server</font>

                </tr>        

        <tr>

          <td align="left" colspan="2">

                        <font color="red"><html:errors/></font>

                </tr> 

                <tr>

          <td align="right">

            File Name

          </td>

          <td align="left">

            <html:file property="theFile"/> 

          </td>

        </tr>
                <tr>

          <td align="center" colspan="2">

            <html:submit>Upload File</html:submit>

          </td>

        </tr>

  </table> 
 </html:form>

        </body>

        </html:html> 
/................................../
<html>

<head>
<title>Success</title>
</head>

<body>
<%
String fileName=(String)request.getAttribute("fileName");
%>

<p align="center"><font size="5" >File Successfully Received</font></p>
<p align="center"><a href="FileUploadAndSave/<%=fileName%>">Click here to download</a></p>
</body>

</html>

/............................../

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">

    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>

  <body>

<a href ="FileUploadAndSave.jsp">Struts File Upload</a>


  </body>
</html>

/...................................../

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
<data-sources></data-sources>
<form-beans>
<form-bean name="FileUploadAndSave" type="com.icon.struts.form.StrutsUploadAndSaveForm"/>
</form-beans>
<action-mappings>

<action
path="/FileUploadAndSave"
type="com.icon.struts.action.StrutsUploadAndSaveAction"
name="FileUploadAndSave"
scope="request"
validate="true"
input="FileUploadAndSave.jsp">
<forward name="success" path="downloaduploadedfile.jsp"/>
</action>
  </action-mappings>

</struts-config>

/............................../ package com.icon.action;

import java.io.File;
import java.io.FileOutputStream;

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

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.upload.FormFile;

import com.icon.struts.form.StrutsUploadAndSaveForm;

/**

* @author Amit Gupta

* @Web http://www.roseindia.net

* @Email [email protected]

*/



/**

 * Struts File Upload Action Form.

 *

*/

public class StrutsUploadAndSaveAction extends Action

{

  public ActionForward execute(

  ActionMapping mapping,

  ActionForm form,

  HttpServletRequest request,

  HttpServletResponse response) throws Exception{

  StrutsUploadAndSaveForm myForm = (StrutsUploadAndSaveForm)form;



  // Process the FormFile

  FormFile myFile = myForm.getTheFile();

  String contentType = myFile.getContentType();

  //Get the file name

  String fileName  = myFile.getFileName();

  //int fileSize = myFile.getFileSize();

  byte[] fileData  = myFile.getFileData();

  //Get the servers upload directory real path name

  String filePath = getServlet().getServletContext().getRealPath("/") +"upload";

  /* Save file on the server */

  if(!fileName.equals("")){  

  System.out.println("Server path:" +filePath);

  //Create file

  File fileToCreate = new File(filePath, fileName);

  //If file does not exists create file  

  if(!fileToCreate.exists()){

  FileOutputStream fileOutStream = new FileOutputStream(fileToCreate);

  fileOutStream.write(myFile.getFileData());

  fileOutStream.flush();

  fileOutStream.close();

  } 

  }

  //Set file name to the request object

  request.setAttribute("fileName",fileName);



  return mapping.findForward("success");

  }

} 

/....................../ package com.icon.struts.form;

import org.apache.struts.action.ActionForm;
import org.apache.struts.upload.FormFile;



/**
* @author Amit Gupta
* @Web http://www.roseindia.net
* @Email [email protected]
*/

/**
 * Form bean for Struts File Upload.
 *
*/
public class StrutsUploadAndSaveForm extends ActionForm
{
  /**
     * 
     */
    private static final long serialVersionUID = 1L;
private FormFile theFile;

  /**
 * @return Returns the theFile.
 */
  public FormFile getTheFile() {
  return theFile;
  }
  /**
 * @param theFile The FormFile to set.
 */
  public void setTheFile(FormFile theFile) {
  this.theFile = theFile;
  }
} 

I'm sendin complete code when iam click on upload button this eroor is displaying on browser please help me. type Status report message No action instance for path /FileUploadAndSave could be created description The server encountered an internal error (No action instance for path /FileUploadAndSave could be created) that prevented it from fulfilling this request.

View Answers









Related Tutorials/Questions & Answers:
No action instance for path
No action instance for path  <%@ taglib uri="http...; </form-beans> <action-mappings> <action path...; <body bgcolor="white"> <html:form action="/FileUploadAndSave
instance
instance  What is the exact need of declaring a variable as instance
Advertisements
INSTANCE
INSTANCE  PLEASE TELL ME THE EXACT MEANING OF INSTANCE?AND EXPLAIN
no action mapped for action - Struts
no action mapped for action  Hi, I am new to struts. I followed...: There is no Action mapped for action name HelloWorld
Action and ActionSupport
Action and ActionSupport  Difference between Action and ActionSupport.... The developer implements this interface of accessing string field in action... for implements Action and some other interfaces and provides some feature like data
Understanding Struts Action Class
_TO_REPLACE_5 <action path="... Understanding Struts Action Class       In this lesson I will show you how to use Struts Action
path classpath
path classpath  EXPLAIN PATH AND CLASSPATH ? DIFF send me ans plz..., Path is system wide variable that tells where to find your commands. Lets... be in path. While Classpath is Enviroment Variable that tells JVM or Java Tools where
Path was not found
Path was not found  The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path
Action form
Action form  how to store details from user and how to create asp file or etc
UISlider action
UISlider action  Hi, How to capture and use UISlider action? Thanks   Hi, Following code might helpful. -(IBAction)changeSlider:(id)sender { NSString *value= [[NSString alloc] initWithFormat:@" Value %d
Action Listeners
Action Listeners  Please, could someone help me with how to use action listeners I am creating a gui with four buttons. I will like to know how to apply the action listener to these four buttons.   Hello Friend, Try
Struts 2 action-validation.xml not loading
error SERVER : Caught exception while loading file package/action-validation.xml Connection refused: Connect - (unknown location) The path of my action...Struts 2 action-validation.xml not loading  Hi All, I am getting
Struts Action Chaining
Struts Action Chaining  Struts Action Chaining
autocall for sturts action class - Struts
the ActionServlet Instance action org.apache.struts.action.ActionServlet...autocall for sturts action class  Hi All, We are developing a web application with struts frame work. In this project I have to call an action
Modifying the Path Example.
or new path. End the PHP tag.ADS_TO_REPLACE_2 Now begin the form action and call...Modifying the Path In this example, you will learn how to modify the corrupted path using $outpath command in PHP. This command will modify the path
Fileupload from source path to destination path
Fileupload from source path to destination path  first we will create... source path &Destination path fields and BOTH INPUT TYPES ARE "TEXT" we will give source path as statically where the .doc or .rtf files path will be their.and
Action Script 'source' attribute example
Action Script 'source' attribute example       In the example below an action.... This .as file instance is brought through the source attribute in <mx
absolute path in php - PHP
absolute path in php  how to get absolute path in php
Error in context path
Error in context path   I Tried a Struts2 Login application having following class as Action class.. package com.actions; import... = request.getContextPath(); System.out.println("Context Path " + contextPath
ActionMapping and is the Action Mapping specified
ActionMapping and is the Action Mapping specified  What is ActionMapping and is the Action Mapping specified
What is Action Class?
What is Action Class?  What is Action Class? Explain with Example
the Action Mapping specified
the Action Mapping specified  How is the Action Mapping specified
Action Configuration - Struts
Action Configuration  I need a code for struts action configuration in XML
instance varaiable
instance varaiable  if we create a class which has two instance variable but don't create object of that class then what is called that instance variable??? bcoz they didn't allocate memory
unrecognized selector sent to instance
in xcode. unrecognized selector sent to instance   This kind of error occurs, when the given "selector action" is not named properly. For example...:@"Email" style:UIBarButtonItemStylePlain target:self action:@selector(xyz
How to use Java Path class?
create instance of Path class it wont create file or directory. To create actual.... If you create the instance of Path class by providing some path...java.nio.file.Path Class -  How to use Java Path class? In this tutorial
path setting - JSP-Servlet
path setting  Hi, friends How to set the oracle 10g path on browser to servlet program
what is instance
what is instance   what is the difference between instance and object   Instance refers to the copy of the object at a particular time... there is an value. int[] arr={1,2,3}; Instance - when there is a declaration for class
what is instance
what is instance   what is the difference between instance and object   Instance refers to the copy of the object at a particular time... there is an value. int[] arr={1,2,3}; Instance - when there is a declaration for class
what is instance
what is instance   what is the difference between instance and object   Instance refers to the copy of the object at a particular time... there is an value. int[] arr={1,2,3}; Instance - when there is a declaration for class
what is instance
what is instance   what is the difference between instance and object   Instance refers to the copy of the object at a particular time... there is an value. int[] arr={1,2,3}; Instance - when there is a declaration for class
what is instance
what is instance   what is the difference between instance and object   Instance refers to the copy of the object at a particular time... there is an value. int[] arr={1,2,3}; Instance - when there is a declaration for class
Calling Action on form load - Struts
application: <action path="/logoff" type...Calling Action on form load  Hi all, is it possible to call... this list is coming from the action which i m calling before the page is being
Action without a form.
Action without a form.  Can I have an Action without a form
Struts Action Class
Struts Action Class  What happens if we do not write execute() in Action class
Jsp Action Tags
Jsp Action Tags  how can i use jsp forward action tag?i want examples
ModuleNotFoundError: No module named 'path'
ModuleNotFoundError: No module named 'path'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'path' How to remove the ModuleNotFoundError: No module named 'path' error
path - Java Beginners
meaning of path and classpath  what is the meaning of path and classpath. How it is set in environment variable.  Path and ClassPath in in JAVAJava ClassPath Resources:-http://www.roseindia.net/java/java-classpath.shtml
instance variables - Java Beginners
instance variables  instance variables
how to set class path
how to set class path  how to set class path in java
ModuleNotFoundError: No module named 'action'
ModuleNotFoundError: No module named 'action'  Hi, My Python... 'action' How to remove the ModuleNotFoundError: No module named 'action'... to install padas library. You can install action python with following command
action tag - Struts
action tag  Is possible to add parameters to a struts 2 action tag? And how can I get them in an Action Class. I mean: xx.jsp Thank you
Action Or DispatchAction - Development process
Action Or DispatchAction   Hi, Action class has execute() only where as dispatchaction class has multiple methods. plz tell me when to use action and dispatchaction.can we use multiple actions in Action class. Thanks Prakash
JSP Forward action
JSP Forward action  Jsp forward action tag examples
Struts Action Classes
Struts Action Classes  1) Is necessary to create an ActionForm to LookupDispatchAction. If not the program will not executed. 2) What is the beauty of Mapping Dispatch Action
RADIO FROM JSP TO ACTION.
RADIO FROM JSP TO ACTION.  Hi frds, how to get the selected multiple radio button values from jsp to action
appdelegate instance
appdelegate instance  Hi, How to get appdelegate instance in some other part of the application? Thanks   Hi, Following code can be used to get the instance of Appdelete. MyAppDelegate *appDelegate = (MyAppDelegate
path problem - Java Beginners
path problem  I dont know how to set the path. What path should we...-FINAL-20081019.jar in jdk's lib folder. I entered path as "C:\Program Files\Java\jdk1.6.0_07\lib" , is this correct? Becoz even after this path compilation
JSP Action Tag
JSP Action Tag   Defined JSP Action Tag ?   Action tag... JSP action tags to either link to a Java Bean set its properties, or get its properties. syntax of Action Tag :ADS_TO_REPLACE_1 <jsp:action attributes />
Action classes in struts
Action classes in struts  how many type action classes are there in struts   Hi Friend, There are 8 types of Action classes: 1.ForwardAction class 2.DispatchAction class 3.IncludeAction class 4.LookUpDispatchAction

Ads