You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sajidbigler <sa...@gmail.com> on 2009/03/16 11:53:13 UTC

Fileupload : Restricted contentType is working fine but no proper error message is shown to user

Hi,

Please help me to show error messages.when we restrict the contentTypes as
shown in the link

http://struts.apache.org/2.0.11.1/docs/file-upload-interceptor.html

The contents are restricted but the error wont be shown to end user how to
make it work please help me!


struts.xml


		<action name="MMSUpload"
			class="com.teleparadigm.mms.application.mms.MMSUploadAction">
			<interceptor-ref name="i18n" />
			<interceptor-ref name="fileUpload">
				
					image/png,image/gif,image/jpeg
				
			</interceptor-ref>
			<interceptor-ref name="basicStack" />
			<interceptor-ref name="validation" />
			<result name="input">/pages/ComposeMMS.jsp</result>
			<result name="error">/pages/ComposeMMS.jsp</result>
			<result>/pages/upload_success.jsp</result>
		</action>


Thanks,

Sajid
-- 
View this message in context: http://www.nabble.com/Fileupload-%3A-Restricted-contentType-is-working-fine-but-no-proper-error-message-is-shown-to-user-tp22535689p22535689.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Fileupload : Restricted contentType is working fine but no proper error message is shown to user

Posted by sajidbigler <sa...@gmail.com>.
Error on Console

Mar 16, 2009 4:50:49 PM
com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
SEVERE: Content-Type not allowed: upload "simplifiedapi.pdf"
"upload__1ed47216_1200f02e810__8000_00000001.tmp" application/pdf

Error on Browser

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it
from fulfilling this request.

exception

java.lang.NullPointerException
	java.io.FileInputStream.<init>(FileInputStream.java:103)

com.teleparadigm.mms.application.smssubcription.SMSSubscriptionAction.execute(SMSSubscriptionAction.java:89)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	java.lang.reflect.Method.invoke(Method.java:585)

com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)

com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)

com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:249)

org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)

com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)

com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)

com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)

com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:306)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:148)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468)

org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)

note The full stack trace of the root cause is available in the Apache
Tomcat/6.0.16 logs.
-- 
View this message in context: http://www.nabble.com/Fileupload-%3A-Restricted-contentType-is-working-fine-but-no-proper-error-message-is-shown-to-user-tp22535689p22536214.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Fileupload : Restricted contentType is working fine but no proper error message is shown to user

Posted by sajidbigler <sa...@gmail.com>.
I have included this but still errors wont be send to end user and more over
surprizingly why the forum trims these lines when i copy/paste from my
struts.xml :(

image/png,image/gif,image/jpeg
-- 
View this message in context: http://www.nabble.com/Fileupload-%3A-Restricted-contentType-is-working-fine-but-no-proper-error-message-is-shown-to-user-tp22535689p22536171.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Fileupload : Restricted contentType is working fine but no proper error message is shown to user

Posted by Dave Newton <ne...@yahoo.com>.
sajidbigler wrote:
> why forum skips
> 
> files \MMSApplication\WebRoot\WEB-INF\lib in bracket and param
> name="allowedTypes" in struts.xml while i post it ? :(
> 
> application/vnd.ms-excel

Probably because it tries to interpret tags as actual tags; that's why 
using the mailing list directly and posting plain-text emails is the 
most reliable way to convey information.

Barring that you could use a code snippet service like pastebin/etc. and 
eliminate all possible user errors.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Fileupload : Restricted contentType is working fine but no proper error message is shown to user

Posted by sajidbigler <sa...@gmail.com>.
why forum skips

files \MMSApplication\WebRoot\WEB-INF\lib in bracket and param
name="allowedTypes" in struts.xml while i post it ? :(

application/vnd.ms-excel
-- 
View this message in context: http://www.nabble.com/Fileupload-%3A-Restricted-contentType-is-working-fine-but-no-proper-error-message-is-shown-to-user-tp22535689p22536405.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Fileupload : Restricted contentType is working fine but no proper error message is shown to user

Posted by Dave Newton <ne...@yahoo.com>.
sajidbigler wrote:
> i have done and followed all steps and following are the jars in my
> application(MMSApplication\WebRoot\WEB-INF\lib)
> 
> commons-beanutils-1.7.0.jar
> commons-fileupload-1.2.1.jar
> commons-io-1.4.jar
> commons-logging-1.0.4.jar
> commons-logging-api-1.1.jar
> commons-validator-1.3.1.jar
> dwr-1.1.1.jar
> freemarker-2.3.13.jar
> json-lib-2.1.jar
> jug-2.0.0.jar
> jxl.jar
> mysql-connector-java-5.0.4-bin.jar
> ognl-2.6.11.jar
> struts2-config-browser-plugin-2.1.6.jar
> struts2-convention-plugin-2.1.6.jar
> struts2-core-2.1.6.jar
> struts2-dojo-plugin-2.1.6.jar
> struts2-dwr-plugin-2.1.6.jar
> struts2-jasperreports-plugin-2.1.6.jar
> struts2-jfreechart-plugin-2.1.6.jar
> struts2-jsf-plugin-2.1.6.jar
> struts2-testng-plugin-2.1.6.jar
> xpp3_min-1.1.3.4.O.jar
> xstream-1.2.2.jar
> xwork-2.1.2.jar

You have a large number of plugins, many of which introduce their own 
dependencies, which you do not list. This may not be the source of your 
immediate problem, but is almost certainly not what you want. For 
example, the Jasper Reports plugin requires.. Jasper Reports, and its 
dependencies, which you don't list.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Fileupload : Restricted contentType is working fine but no proper error message is shown to user

Posted by sajidbigler <sa...@gmail.com>.
I think if jars are not included properly it would  not even allow me to
submit correct files() but i can do every thing and more over its telling
the file is not a correct contentType but no message is shown to user in
browser :(
i even kept

struts.properties

struts.custom.i18n.resources=MMSApplicationMessages
struts.messages.error.uploading=General Error could not upload files
struts.messages.error.file.too.large=File Size is too Large than expected
struts.messages.error.content.type.not.allowed=uploaded file does not match
the expected content types specified



i have done and followed all steps and following are the jars in my
application(MMSApplication\WebRoot\WEB-INF\lib)

commons-beanutils-1.7.0.jar
commons-fileupload-1.2.1.jar
commons-io-1.4.jar
commons-logging-1.0.4.jar
commons-logging-api-1.1.jar
commons-validator-1.3.1.jar
dwr-1.1.1.jar
freemarker-2.3.13.jar
json-lib-2.1.jar
jug-2.0.0.jar
jxl.jar
mysql-connector-java-5.0.4-bin.jar
ognl-2.6.11.jar
struts2-config-browser-plugin-2.1.6.jar
struts2-convention-plugin-2.1.6.jar
struts2-core-2.1.6.jar
struts2-dojo-plugin-2.1.6.jar
struts2-dwr-plugin-2.1.6.jar
struts2-jasperreports-plugin-2.1.6.jar
struts2-jfreechart-plugin-2.1.6.jar
struts2-jsf-plugin-2.1.6.jar
struts2-testng-plugin-2.1.6.jar
xpp3_min-1.1.3.4.O.jar
xstream-1.2.2.jar
xwork-2.1.2.jar


struts.xml

		<action name="SMSSubscription"
		
class="com.teleparadigm.mms.application.smssubcription.SMSSubscriptionAction">
			<interceptor-ref name="i18n" />
			<interceptor-ref name="fileUpload">
				
					application/vnd.ms-excel
				
			</interceptor-ref>
			<interceptor-ref name="basicStack" />
			<interceptor-ref name="validation" />
			<result name="input">
				/pages/ComposeSMSSubscriptions.jsp
			</result>
			<result name="error">
				/pages/ComposeSMSSubscriptions.jsp
			</result>
			<result>/pages/upload_success.jsp</result>
		</action>


-- 
View this message in context: http://www.nabble.com/Fileupload-%3A-Restricted-contentType-is-working-fine-but-no-proper-error-message-is-shown-to-user-tp22535689p22536371.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Fileupload : Restricted contentType is working fine but no proper error message is shown to user

Posted by ravindra <ra...@btpsoft.com>.
Check this page,

	http://cwiki.apache.org/WW/file-upload.html

Make sure you have all jar files and other properties they mentioned in it.


-----Original Message-----
From: sajidbigler [mailto:sajidbigler@gmail.com] 
Sent: Monday, March 16, 2009 4:47 PM
To: user@struts.apache.org
Subject: RE: Fileupload : Restricted contentType is working fine but no
proper error message is shown to user


Hi Ravindra,

I have done it but really dont no why it dint got pasted properly on forum

<action name="MMSUpload"
	
class="com.teleparadigm.mms.application.mms.MMSUploadAction">
			<interceptor-ref name="i18n" />
			<interceptor-ref name="fileUpload">
				image/png,image/gif,image/jpeg
			</interceptor-ref>
			<interceptor-ref name="basicStack" />
			<interceptor-ref name="validation" />
			<result name="input">/pages/ComposeMMS.jsp</result>
			<result name="error">/pages/ComposeMMS.jsp</result>
			<result>/pages/upload_success.jsp</result>
		</action>

-- 
View this message in context:
http://www.nabble.com/Fileupload-%3A-Restricted-contentType-is-working-fine-
but-no-proper-error-message-is-shown-to-user-tp22535689p22536107.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Fileupload : Restricted contentType is working fine but no proper error message is shown to user

Posted by sajidbigler <sa...@gmail.com>.
Hi Ravindra,

I have done it but really dont no why it dint got pasted properly on forum

<action name="MMSUpload"
			class="com.teleparadigm.mms.application.mms.MMSUploadAction">
			<interceptor-ref name="i18n" />
			<interceptor-ref name="fileUpload">
				
					image/png,image/gif,image/jpeg
				
			</interceptor-ref>
			<interceptor-ref name="basicStack" />
			<interceptor-ref name="validation" />
			<result name="input">/pages/ComposeMMS.jsp</result>
			<result name="error">/pages/ComposeMMS.jsp</result>
			<result>/pages/upload_success.jsp</result>
		</action>

-- 
View this message in context: http://www.nabble.com/Fileupload-%3A-Restricted-contentType-is-working-fine-but-no-proper-error-message-is-shown-to-user-tp22535689p22536107.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Fileupload : Restricted contentType is working fine but no proper error message is shown to user

Posted by ravindra <ra...@btpsoft.com>.
You have to mention param -allowed types.

<interceptor-ref name="fileUpload">
	<param
name="allowedTypes">image/png,image/gif,image/jpeg,text/plain</param>
			</interceptor-ref>
</action>

-----Original Message-----
From: sajidbigler [mailto:sajidbigler@gmail.com] 
Sent: Monday, March 16, 2009 4:23 PM
To: user@struts.apache.org
Subject: Fileupload : Restricted contentType is working fine but no proper
error message is shown to user


Hi,

Please help me to show error messages.when we restrict the contentTypes as
shown in the link

http://struts.apache.org/2.0.11.1/docs/file-upload-interceptor.html

The contents are restricted but the error wont be shown to end user how to
make it work please help me!


struts.xml


		<action name="MMSUpload"
	
class="com.teleparadigm.mms.application.mms.MMSUploadAction">
			<interceptor-ref name="i18n" />
			<interceptor-ref name="fileUpload">
				
					image/png,image/gif,image/jpeg
				
			</interceptor-ref>
			<interceptor-ref name="basicStack" />
			<interceptor-ref name="validation" />
			<result name="input">/pages/ComposeMMS.jsp</result>
			<result name="error">/pages/ComposeMMS.jsp</result>
			<result>/pages/upload_success.jsp</result>
		</action>


Thanks,

Sajid
-- 
View this message in context:
http://www.nabble.com/Fileupload-%3A-Restricted-contentType-is-working-fine-
but-no-proper-error-message-is-shown-to-user-tp22535689p22535689.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org