Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

cannot post to servlet  RSS feed

Gerome Kawa
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

<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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!