Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts No action instance for path

Have Programming Question? Ask it here!
 
 
 


tulasi.vishnu
No action instance for path
0 Answer(s)      2 years and 2 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.


Advertisement
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
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
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 variables - Java Beginners
instance variables  instance variables
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
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
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
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
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
static & instance - Java Beginners
static & instance  what is different between static variable and instance variable .? plz explain with example. and when we can use static variable and when can use instance variable.    public class Main
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">
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
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
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
Object reference not set to an instance of an object
Object reference not set to an instance of an object  Object reference not set to an instance of an object
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
How to Create Instance using PHP
How to Create Instance using PHP  Hi, How to create an instance class in PHP program. Can someone explain or suggest any online reference how to create an Instance class in PHP. Thanks
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
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
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
path setting - JSP-Servlet
path setting  Hi, friends How to set the oracle 10g path on browser to servlet program
Instance variable in java
Instance variable in java In this section you will learn about Instance... in java, they are as follows : Local variable Instance Variable class/static variable Instance variable : Instance variable are declared
Understanding Struts Action Class
controller (ActionServlet) slects an appropriate Action and creates an instance... the TestAction class. <action path="... Understanding Struts Action Class   
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
how to set class path
how to set class path  how to set class path in java
Struts Action Chaining
Struts Action Chaining  Struts Action Chaining
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
Explain instance in java - Java Interview Questions
Explain instance in java  Hi Friends, can you explain instance in java. In general instance means "occurence of something" . In java what is instance
PHP hide file path
PHP hide file path  PHP to read a path and convert that to the virtual link
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
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
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
 

 

 

DMCA.com