Welcome!

I think your problem could be as simple as the "/" at the start of
your class name:

<servlet path="/myFormHandler" class="/
xxx.xxx.xxx.myprojects.provaupload.server.MyFormHandler"/>

Try changing it to this:

<servlet path="/myFormHandler"
class="xxx.xxx.xxx.myprojects.provaupload.server.MyFormHandler"/>

Now, if that isn't the problem (maybe the "/" was a typo in your post,
but not in your gwt.xml), then I would ask you to make sure that you
are compiling your servlet (javac from the command line, or an IDE
such as Eclipse will do this automatically). The compiled servlet
class needs to be on your classpath when you run hosted mode.

Hope that helps.

- Isaac


On Tue, Apr 7, 2009 at 1:41 PM, Nickelnext <[email protected]> wrote:
>
> Hello everyone,
>
> this is my first post and i pray i did not do anything wrong by write
> it here.
> I've been looking for the solution of my problem for days over the
> web, but i did not find what i need so, i'm posting right here at
> google groups hoping someone more skilled than me and very patient
> could help me.
>
> Before start, i let u know how my workspace is configured:
> package: com.my.site.myprojects.provaupload
> public >>css, html,
> ProvaUpload.gwt.xml
> package: com.my.site.myprojects.provaupload.client
>>>ProvaUpload.java
> package: com.my.site.myprojects.provaupload.server
>>>MyFormHandler.java
>
> Now, here's my problem:
>
> I need an upload form to upload a small file on the server, i have my
> simple ProvaUpload.java like this
>
> public void onModuleLoad() {
>        final FormPanel form = new FormPanel();
>        form.setAction(GWT.getModuleBaseURL() + "/myFormHandler");
>
>        // Because we're going to add a FileUpload widget, we'll need
> to set the
>        // form to use the POST method, and multipart MIME encoding.
>        form.setEncoding(FormPanel.ENCODING_MULTIPART);
>        form.setMethod(FormPanel.METHOD_POST);
>
>        VerticalPanel panel = new VerticalPanel();
>        form.setWidget(panel);
>
>        // Create a FileUpload widget.
>        FileUpload upload = new FileUpload();
>        upload.setName("uploadFormElement");
>
>        panel.add(upload);
>        Button button2 = new Button("Submit", new ClickListener() {
>            public void onClick(Widget sender) {
>                form.submit();
>            }
>        });
>        // Add a 'submit' button.
>        panel.add(button2);
>
>        // Add an event handler to the form.
>        form.addFormHandler(new FormHandler() {
>
>            public void onSubmitComplete(FormSubmitCompleteEvent
> event) {
>                // When the form submission is successfully completed,
> this
>                // event is
>                // fired. Assuming the service returned a response of
> type
>                // text/html,
>                // we can get the result text here (see the FormPanel
>                // documentation for
>                // further explanation).
>                Window.alert(event.getResults());
> //              Window.alert("Done");
>            }
>
>            public void onSubmit(FormSubmitEvent event) {
>                // TODO Auto-generated method stub
>                Window.alert("upload in progress");
>            }
>        });
>        RootPanel.get().add(form);
>    }
>
> found the code over the web.
>
> Now my problem is here: i don't need any of the gwt (ajax) async
> callback or anything: i only need a simple servlet that takes care of
> my uploaded file, so my MyFormHandler.java is like this
>
> public class MyFormHandler extends HttpServlet {
>
>        private static final long serialVersionUID = 1L;
>
>        public void service(HttpServletRequest req, HttpServletResponse resp)
>            throws ServletException, IOException {
>
>        resp.setContentType("text/html");
>
>        FileItem uploadItem = getFileItem(req);
>        if(uploadItem == null) {
>            resp.getWriter().write("NO-SCRIPT-DATA");
>            return;
>        }
>
>        resp.getWriter().write(new String(uploadItem.get()));
>    }
>    private FileItem getFileItem(HttpServletRequest req) {
>        FileItemFactory factory = new DiskFileItemFactory();
>        ServletFileUpload upload = new ServletFileUpload(factory);
>        upload.setFileSizeMax(100000000);
>        try {
>            List items = upload.parseRequest(req);
>            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;
>        }http://groups.google.com/group/Google-Web-Toolkit/
> browse_thread/thread/50b6a7fee3262a18
>
>        return null;
>    }
>
> }
>
> also this one found on the web. That's right, i should have done it by
> myself but i'm trying to figure out how the whole gwt works so...no
> time for it.
>
> Now, what i don't understand which of the two files (the web.xml one
> or the ProvaUpload.gwt.xml one) i have to change (do i need to add the
> <servlet ... /> in the second one or must i call the <servlet name>
> <servlet mapping> in the first one?
> And in which way? Because i tried a lot, but the only answer i get is
> " [WARN] Resource not found: myFormHandler; (could a file be missing
> from the public path or a <servlet> tag misconfigured in module
> xxx.xxx.xxx.provaupload.ProvaUpload.gwt.xml ?)"
>
> I'll post also the content of my two xml files so you can check:
>
> web.xml (in blablabla/tomcat/web-inf)
> <servlet>
>                <servlet-name>MyFormHandler</servlet-name>
>                <servlet-
> class>xxx.xxx.xxx.myprojects.provaupload.server.MyFormHandler</servlet-
> class>
>        </servlet>
>        <servlet-mapping>
>                <servlet-name>MyFormHandler</servlet-name>
>                <url-pattern>/*</url-pattern>
>        </servlet-mapping>
>
> and the blabla.gwt.xml
>
>  <servlet path="/myFormHandler" class="/
> xxx.xxx.xxx.myprojects.provaupload.server.MyFormHandler"/>
>
> So...i appreciate any help, and hope at least one of you survived to
> this long post.
> Thank you all in advance and sorry for the bad english
>
> - Nickelnext
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to