Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Pedro Gilbert   on Mar 30 In Java Category.

  
Question Answered By: Chau Tran   on Mar 30

I think you created a servlet but you must use the
StrutsAction Servlet in your web.xml and create an
Action class and struts-config.xml (which this new
action sepecified in it with your path sendToBulk.do)

I don't know that you are aware of these issues or
not?
So you can not use a Servlet for your purpose you must
use struts  ActionServlet as shown in this snip of
web.xml


<servlet>
<servlet-name>action</servlet-name>

<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

And the create an Action class and then configure it
in a struts-config.xml file which is placed beside
web.xml in WEB-INF directory and specify in its
configuration your path (for example: sendToBlock) as
shown in the following snip of struts-config.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts
Configuration 1.1//EN"

"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

<struts-config>

<!-- Form Bean Definitions -->
<form-beans>
<form-bean name="testForm"
type="com.test.web.forms.TestForm"/>

</form-beans>

<action-mappings>
<action path="/sendToBulk"
type="com.test.web.actions.TestAction"
parameter="dispatch"
name="testForm" scope="request"
validate="false" input="/main/test.jsp">
</action>
</action-mappings>

</struts-config>

You must configure your struts completely to use its
features!

> Dear mr. dolatshahi!
tnx for u'r answer!
for upload  file with struts i write a :
1- (sendToBulk.do) ActionServlet for upload a file
with struts.
2- create a form bean that have property (FormFile)
with setter and getter Method.
3- create a jsp file that u see it's
code...(Multi-part form)
4- add a commons-upload,jar to classpath.
but when i run my project(for upload file) get this
error : IO EXception :Corrupt form data: premature
ending

however! can i use from FormFile Class that struts is
inroduce to me? (this class have a getInputsetram
method that get to me content of uploaded file)

Share: