File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes cannot post to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "cannot post to servlet" Watch "cannot post to servlet" New topic

cannot post to servlet

Gerome Kawa
Ranch Hand

Joined: Dec 05, 2002
Posts: 61
I have the following structure for my web application:

- webapps
- xyztransmission ( xml_input.html)
- servlets
- WEB-INF (web.xml)
- classes
- servlets (AcceptAndSaveTransmittedFile.class)

The xml_input.html file:

<TITLE>XML Input to Transmission Emulator</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<style type="text/css">
body, td, select, input, textarea {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8pt;
color: #001E4C;
h3 {
background-color : #E5EFF2
.normformbutton {
BORDER-RIGHT: #000 thin solid;
BORDER-TOP: thin outset #9999CC;
BORDER-LEFT: thin outset #9999CC;
COLOR: white;
BORDER-BOTTOM: #000 thin solid;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
HEIGHT: 22px;
width: 82px;
<form action="/processrequest" method="POST">
<table width="100%" cellspacing="0" cellpadding="3">
<td> </td>
<td>Please paste your XML in the box below and press submit</td>
<td> </td>
<td> </td>
<td><textarea name="xml" cols="120" rows="20"></textarea></td>
<td> </td>
<td> </td>
<td>Send XML To HUB</td>
<td><input type="submit" value="submit" class="normformbutton"></td>
<td> </td>

My web.xml is as follows:
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "">
<display-name>XYZ Emulator Servlet</display-name>
<description>Receives xml files and saves them in file system</description>

After starting up tomcat and putting the URL
I get to see my html file correctly
But when I press the submit button, expecting the servlet 'AcceptAndSaveTransmittedFile 'to be called I get HTTP 404 error saying " The requested resource (/processrequest) is not available."

Can anyone tell me where I am going wrong ?

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

<form action="processrequest" method="POST">

Prepending the forward slash tells your browser to look for a context named "processrequest" instead of looking for "processrequest" in the "hubtransmission" context.

Also, you're missing he close form tag.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: cannot post to servlet
It's not a secret anymore!