SwiftMango
SwiftMango

Reputation: 15284

Submit a form and get 404 empty response back

I have a servlet:

<servlet>
    <servlet-name>UploadServlet</servlet-name>
    <servlet-class>com.timelessmind.ttms.server.UploadServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>UploadServlet</servlet-name>
    <url-pattern>/attachment</url-pattern>
</servlet-mapping>

And in the code, I have a submit FormPanel with a FileUpload:

form.setAction("/attachment");
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);

And submit button:

submitButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            form.submit();
        }
    });

SubmitCompleteHandler:

Window.alert(event.getResults());

And the response is like:

HTTP Status 404 -

type Status report

message

description The requested resource () is not available.

The requested source is an empty bracket, which I could not figure out why?

Upvotes: 0

Views: 194

Answers (2)

ved
ved

Reputation: 909

You can also try complete url in action method(http://yoururl:8080/MyApp/attachment)

Upvotes: 0

Majid Laissi
Majid Laissi

Reputation: 19778

Please check your firebug network console to see where exactly is the form submitted.

It is most certainly submitting in http://yoururl:8080/attachment instead of http://yoururl:8080/MyApp/attachment

To solve your problem, try removing the slash at the beginning:

form.setAction("attachment");

Otherwise, add your application context:

form.setAction("/MyApp/attachment");

Upvotes: 2

Related Questions