Hardik Mishra
Hardik Mishra

Reputation: 14887

GWT Fileupload Using Servlet with GUICE

We are using GWTP with Guice. I want to upload a file. For that I have written a Servlet.

I am using this GWT File UPload Example. But Servlet is not getting called. I think its the problem with GuiceFilter. Below is my web.xml entry.


Web.xml

<listener>
        <listener-class>com.nextenders.server.guice.GuiceServletConfig</listener-class>
    </listener>
<filter>
    <filter-name>guiceFilter</filter-name>
    <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>guiceFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


<servlet>
    <servlet-name>FileUploadServlet</servlet-name>
    <servlet-class>com.nextenders.server.guice.actions.FileUploadServlet</servlet-class>   
</servlet>

<servlet-mapping>
    <servlet-name>FileUploadServlet</servlet-name>
    <url-pattern>/upload/fileUpload</url-pattern>
</servlet-mapping>

Any pointers would be great help.

Upvotes: 0

Views: 1363

Answers (2)

Hardik Mishra
Hardik Mishra

Reputation: 14887

I found out the problem and solved on my own. Here is the answer:

It was not the problem with the GUICE Servlet Filter.

The problem was with Coade statements placing. FileUpload com.google.gwt.user.client.ui.FileUpload should be used with FormPanel.

FileUpload must be used with FormPanel if it is to be submitted to a server.

I had used GWT file upload earlier but skipped thorough my mind.

Upvotes: 0

Christian Goudreau
Christian Goudreau

Reputation: 411

If you're using Guice, you mush use Guice ServletModule class to set up your servlets.

Ex: serve("/upload/pictures").with(PictureUploader.class);

Documentation: http://code.google.com/p/google-guice/wiki/ServletModule

Cheers,

Upvotes: 1

Related Questions