Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7593967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:18:11+00:00 2026-05-30T21:18:11+00:00

I am trying to work with servlet in GWT. and i found Error. No

  • 0

I am trying to work with servlet in GWT. and i found
Error.

   No file found for: /uploadfile/uploadFileServlet

i want to browse a file and send it on the server side.

i went through many solution provided by the experts. But i am not able to find my mistake

some one plz help to solve it.

Client Side

package uploadfile.client;
public class Uploadfile implements EntryPoint {

    @SuppressWarnings("deprecation")
    public void onModuleLoad() {
        // TODO Auto-generated method stub
            final FormPanel uploadForm = new FormPanel(); 

            uploadForm.setAction(GWT.getModuleBaseURL() +"uploadFileServlet"); 

            uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); 
            uploadForm.setMethod(FormPanel.METHOD_POST); 

            // Create a panel to hold all of the form widgets. 
            VerticalPanel panel = new VerticalPanel(); 
            uploadForm.setWidget(panel); 

            // Create a FileUpload widget. 
            FileUpload upload = new FileUpload(); 
            upload.setName("uploadFormElement"); 
            panel.add(upload); 

            // Add a 'submit' button. 
            Button uploadSubmitButton = new Button("Submit"); 
            panel.add(uploadSubmitButton); 
            uploadSubmitButton.addClickListener(new ClickListener() { 
              public void onClick(Widget sender) { 
                uploadForm.submit(); 
              } 
            }); 
            uploadForm.addFormHandler(new FormHandler() { 
              public void onSubmit(FormSubmitEvent event) { 
              } 
              public void onSubmitComplete(FormSubmitCompleteEvent event) { 
                Window.alert(event.getResults()); 
              } 
            }); 
            RootPanel.get().add(uploadForm); 
    }

}

Server side

package uploadfile.server;


public class UploadFileServlet extends HttpServlet implements Servlet 
{ 
   private static final long serialVersionUID = 8305367618713715640L; 

    protected void doGet(HttpServletRequest request, 
        HttpServletResponse response) 
                        throws ServletException, IOException { 
  doPost(request, response);
 }

 protected void doPost(HttpServletRequest request, 
        HttpServletResponse response) 
                        throws ServletException, IOException { 

    response.setContentType("text/plain"); 
    FileItem uploadItem = getFileItem(request); 
    if (uploadItem == null) { 
            response.getWriter().write("NO-SCRIPT-DATA"); 
            return; 
    } 
    byte[] fileContents = uploadItem.get(); 
    //TODO: add code to process file contents here. We will just print 

    System.out.println(new String(fileContents)); 
    response.getWriter().write(new String(fileContents)); 
  } 

   private FileItem getFileItem(HttpServletRequest request) { 

  FileItemFactory factory = new DiskFileItemFactory(); 
  ServletFileUpload upload = new ServletFileUpload(factory); 
  try { 
      List items = upload.parseRequest(request); 
      Iterator it = items.iterator(); 
      while (it.hasNext()) { 
          FileItem item = (FileItem) it.next(); 
          if (!item.isFormField() 
                  && "uploadFormElement".equals(item.getFieldName())) { 
              return item; 
          } 
      } 
  } catch (FileUploadException e) { 
      return null; 
  } 
 return null; 
  } 
 } 

web.xml

  <?xml version="1.0" encoding="UTF-8"?>
 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee                  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>fileUploaderServlet</servlet-name>
<servlet-class>uploadfile.server.UploadFileServlet</servlet-class>
</servlet>
<!-- Servlets 
Default page to serve -->

<servlet-mapping>
<servlet-name>fileUploaderServlet</servlet-name>
<url-pattern>/uploadFileServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>Uploadfile.html</welcome-file>
 </welcome-file-list>
</web-app>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:18:12+00:00Added an answer on May 30, 2026 at 9:18 pm

    Am not a GWT developer so it could be different, i think your servlet action url is wrong. You are trying for a servlet with path /uploadfile/uploadFileServlet but your servlet is actually mapped to the url /uploadFileServlet.

    One more thing, there is no need for you to implement Servlet if you are extending HttpServlet unless you have any specific reasons to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to work with the below code: import javax.servlet.*; import javax.servlet.http.*; import java.io.*;
I am trying to do a file upload from gwt-ext without bringing up the
I am trying to call remote servlet from GWT, actually the GWT-RPC doesn't seems
I'm trying to do a jquery GET and i want to send a parameter.
I am trying work out with MERGE statment to Insert / Update Dimension Table
Trying to work with Eclipse for Android (ADT plugin) development at my iMac (2.4Ghz,
Trying to work with groupby so that I can group together files that were
When trying to work with Qt's signal/slot mechanisms over more than one level of
Programming Student here...trying to work on a project but I'm stuck. The project is
I have been trying to work my way through Project Euler, and have noticed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.