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



Home Answers Viewqa Struts No action instance for path
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


tulasi.vishnu
No action instance for path
0 Answer(s)      2 years and 6 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  PLEASE TELL ME THE EXACT MEANING OF INSTANCE?AND EXPLAIN
Advertisements
instance
instance  What is the exact need of declaring a variable as instance
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
export instance sql
export instance sql  How to export instance in sql
Hibernate instance states.
Hibernate instance states.  Explain the types of Hibernate instance states
add a property to instance variable
add a property to instance variable  How to add a property to instance variable in iPhone SDK
Static & Instance variables in java
Static & Instance variables in java  What are the Difference between Static & Instance variables in java
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
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
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
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
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
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
 

 

 

DMCA.com