Home Answers Viewqa Struts No action instance for path

 
 


tulasi.vishnu
No action instance for path
0 Answer(s)      10 months ago
Posted in : Struts

<%@ 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 struts@roseindia.net

*/



/**

 * 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 struts@roseindia.net
*/

/**
 * 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 Pages:
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
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
instance
instance  What is the exact need of declaring a variable as instance
INSTANCE
INSTANCE  PLEASE TELL ME THE EXACT MEANING OF INSTANCE?AND EXPLAIN
Understanding Struts Action Class
controller (ActionServlet) slects an appropriate Action and creates an instance... the TestAction class. <action path="... Understanding Struts Action Class   
creating instance of table in jsp
creating instance of table in jsp  i face senario look kie as follows... to make the instance of the data present in that paarticular table.... how i do...;%@page import="java.sql.*"%> <form method="post" action="update.jsp">
error http status-500 invalid path was requested
; <action path="Add" forward="add.jspx"/> <action path...error http status-500 invalid path was requested  I am using...;forward name="add" path="/Add.do" /> <forward name="welcome" path
error http status-500 invalid path was requested
; <action path="Add" forward="add.jspx"/> <action path...error http status-500 invalid path was requested  I am using...;forward name="add" path="/Add.do" /> <forward name="welcome" path
error http status-500 invalid path was requested
; <action path="Add" forward="add.jspx"/> <action path...error http status-500 invalid path was requested  I am using...;forward name="add" path="/Add.do" /> <forward name="welcome" path
error http status-500 invalid path was requested
path="Add" forward="add.jspx"/> <action path="/Welcome" forward...error http status-500 invalid path was requested  I am using..." path="/Add.do" /> <forward name="welcome" path="/Welcome.do"/>
STRUTS 2 Could not find action or result
on my log: WARNING: Could not find action or result There is no Action mapped for namespace [/] and action name [menujsp] associated with context path...STRUTS 2 Could not find action or result  hiii..i am new to struts 2
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
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
to obtain image path
to obtain image path   i have made a web application in which you can... or BROWSE button . and i am expecting to obtain the complete path of the image from...; </head> <body> &lt;FORM ACTION="upload" METHOD
Modifying the Path Example.
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 in the correct way if it finds any error syntax in the defined path. The $outpath command
File Path compare in java
File Path Comparison :compareTo      File Path Comparison :compareTo... of their path.  For this purpose, we use   compareTo() method
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
Calling Action on form load - Struts
;action path="/logoff" type="org.apache.struts.webapp.example.LogoffAction...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
i am inserting an image into database but it is showing relative path not absolute path
i am inserting an image into database but it is showing relative path not absolute path   hi my first page......... <html> <head>...;</p> <form action="addimage.jsp"> Enter your name:<input type
Action Submit Html
Action Submit Html       Action Submit in Html is used to submit a form, When a user... in the action setting of the <form> tag. Understand with Example The Tutorial
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
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
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
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
Class and Instance
; public int y=3;} What are the class variable? What are the instance variables... = " +b.x);   Instance variables are declared in a class, but outside a method... in the heap, there is a slot in it for each instance variable value. Therefore
Struts Dispatch Action Example
. <action path="/DispatchAction" type... Struts Dispatch Action Example       Struts Dispatch Action
how to set the class path variable in tomcat ?
how to set the class path variable in tomcat ?  description The server encountered an internal error () that prevented it from fulfilling...;/html> .class file is /* File: TestBean.java */ package action
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use... ENCTYPE="multipart/form-data" ACTION="image2" METHOD=POST> <table border
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use... ENCTYPE="multipart/form-data" ACTION="image2" METHOD=POST> <table border
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use... ENCTYPE="multipart/form-data" ACTION="image2" METHOD=POST> <table border
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use... ENCTYPE="multipart/form-data" ACTION="image2" METHOD=POST> <table border
JSF Login Example By Using Component Instance Binding
JSF Login Example By Using Component Instance Binding... value or component instance. Both types of binding requires use of Expression Language (EL) syntax. A component instance can be bound to the bean
Standard Action "jsp:plugin"
Standard Action <jsp:plugin> In this Section, we will discuss about standard action "jsp:plugin" & their implementation using a example. The <jsp:plugin> action is use to download a plugin (an Applet or a Bean
STRUTS ACTION - AGGREGATING ACTIONS IN STRUTS
; <action path="/crudDispatchAction" type... mappings. <action path="/createMappingAction" type...; <action path="/readMappingAction" type="com.bodhtree.CRUDMappingDispatchAction
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
instance variables - Java Beginners
instance variables  instance variables
Hibernate instance states.
Hibernate instance states.  Explain the types of Hibernate instance states
export instance sql
export instance sql  How to export instance in sql
Indexed Vector Array in Action Script 3.0
instance example:- In this example, you can see how to insert value in the indexed array class instance with different data types. Example:- <...; In this example we have create a Array class instance. You use the array access
Static & Instance variables in java
Static & Instance variables in java  What are the Difference between Static & Instance variables in java
add a property to instance variable
add a property to instance variable  How to add a property to instance variable in iPhone SDK
Binding Component Instance to a Bean Property
Binding Component Instance to a Bean Property... properties that are bound to either component value or component instance. Both... instance can be bound to the bean property by referencing the property
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
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
about instance of java
about instance of java  1> what is an instance 2> what..., An Instance creates the reference of an object. An object is a run time entity of the class. Difference: An instance refers to the copy of the object while
What are instance variables?
What are instance variables?   Hi, What are instance variables? thanks   Hi, Each object of the class has its own set of values... (instances of the class).Hence these variables are also known as instance variables

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.