You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Leonard Wolters <l....@chello.nl> on 2002/08/28 00:24:23 UTC

Problems with html:file

Hi there,


I have some questions concerning uploading of files. From
my previous HTML experience I know that for uploading of
files, one can (and should!) use the Oreilly Servlet package.


I get a nasty 'javax.servlet.ServletException: BeanUtils.populate
with root cause: java.lang.IllegalArgumentException: argument type 
mismatch when submitting a file.

Short explanation: I use a dedicated Action for uploading the file. The
idea is that when a user presses the submit button, this action is
triggered and uses the Oreilly Package for successfully receiving the file.

<Code Snipplet A: photo.jsp>

<html:form action="/uploadPhoto" method="POST" enctype="multipart/form-data">
<table border="0" width="100%">
    <tr>
        <td>
            <html:file property="file"/>
        </td>
    </tr>
    <tr>
        <td align="right">
            <html:submit>
                <bean:message key="button.upload"/>
            </html:submit>
        </td>
  </tr>
</table>
</html:form>

<Code Snipplet B: struts-config.xml>

    <action     path="/uploadPhoto"
   type="UploadPhotoAction"
   name="photoForm"
   scope="request"
   input="/photo.jsp">
  </action>


First question:  How is the property 'file' 
being transferred to the photoForm ? As a
string or file ? Is it being transferred to the 
form at all ? I assume it is, since the 
BeanProperties.populate.....

Second question: I can use a Servlet for
uploading the file instead of an action. The
problem then is how to formulize the 'action'
target of the form element. Should I use the
html:form action="http://localhost:8080/IZJNApp/servlet/uploadServlet"
or can I use html:form action="servlet/uploadServlet 
(which is much better since not depending on 
hardcoded localhost and port) Is this possible
and if yes, how ? Does anyone has a good
document about when to use servlets and when
to use actions ?

Third question: (Not very related). I have problems
downloading / viewing the struts config dtd found
at http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd
Where can I find this dtd ?

Last question: (rather simple) How can one
i18n the text on the 'browse' button (the submit
type) ? With other words, I want to replace the
'Browse' text on the submit button.

Perhaps that anyone has general solutions
for this problem, i.e. argument type 
mismatch ?

Thanks in advance,

Leonard

RE: 2000 lbs of Debug logs

Posted by Joe Latty <jo...@team2media.com>.
Here is the top 2 lines from my log4j.properties file:

# Set root category priority to WARN which is above INFO
# This is so we do not get about a billion messages from the struts logger
log4j.rootLogger=WARN, emslog

# This sets up messages for the com.yourPackage.* package
log4j.logger.com.yourPackage=DEBUG

Joe

-----Original Message-----
From: Brandon Goodin [mailto:mail@phase.ws]
Sent: Wednesday, 28 August 2002 8:29 AM
To: Struts Users Mailing List
Subject: 2000 lbs of Debug logs


I use log4j for my logging. When I use struts I get a ton of DEBUG Code
going to my Log File on startup. I have set all debug to 0 in the web xml
for the Action Servlet declaration and it still happens. Is there anyway i
can specify in the log4j config file to prevent this from happening apart
from setting my root logger to INFO?

Brandon


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: 2000 lbs of Debug logs

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 27 Aug 2002, Brandon Goodin wrote:

> Date: Tue, 27 Aug 2002 16:29:18 -0600
> From: Brandon Goodin <ma...@phase.ws>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: 2000 lbs of Debug logs
>
> I use log4j for my logging. When I use struts I get a ton of DEBUG Code
> going to my Log File on startup. I have set all debug to 0 in the web xml
> for the Action Servlet declaration and it still happens. Is there anyway i
> can specify in the log4j config file to prevent this from happening apart
> from setting my root logger to INFO?
>

In Struts 1.1, the "debug" init parameter is totally ignored.  Everything
is configured using the standard Log4J configuration properties (since you
are using Log4J).

The important thing to understand, in order to make this work, is what
logger names the Struts components use.  The convention for Struts (and
the commons packages) is to use the fully qualified class name of the
class originating the log messages.  Thus, you can individually tweak the
log volume from each class to what you need, or turn off everything by
setting the log level for "org.apache.struts" to something like ERROR.
(In Log4J, as in JDK 1.4 logging, log levels are inheritable.)

> Brandon
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


2000 lbs of Debug logs

Posted by Brandon Goodin <ma...@phase.ws>.
I use log4j for my logging. When I use struts I get a ton of DEBUG Code
going to my Log File on startup. I have set all debug to 0 in the web xml
for the Action Servlet declaration and it still happens. Is there anyway i
can specify in the log4j config file to prevent this from happening apart
from setting my root logger to INFO?

Brandon


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>