aspose file tools*
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
Author

cannot post to servlet

Gerome Kawa
Ranch Hand

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

C:\jakarta-tomcat-4.1.30
- webapps
- xyztransmission ( xml_input.html)
- servlets
- WEB-INF (web.xml)
- classes
- servlets (AcceptAndSaveTransmittedFile.class)

*******************************************************************
The xml_input.html file:

<HTML>
<HEAD>
<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;
FONT-SIZE: 8pt;
BORDER-LEFT: thin outset #9999CC;
COLOR: white;
BORDER-BOTTOM: #000 thin solid;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
HEIGHT: 22px;
width: 82px;
BACKGROUND-COLOR: #001E4C;
}
</style>
</HEAD>
<BODY BGCOLOR=#FFFFFF>
<form action="/processrequest" method="POST">
<table width="100%" cellspacing="0" cellpadding="3">
<tr>
<td> </td>
<td>Please paste your XML in the box below and press submit</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><textarea name="xml" cols="120" rows="20"></textarea></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
<table>
<tr>
<td>Send XML To HUB</td>
<td><input type="submit" value="submit" class="normformbutton"></td>
</tr>
</table>
</td>
<td> </td>
</tr>
</table>

</BODY>
</HTML>
*******************************************************************
My web.xml is as follows:
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>XYZ Emulator Servlet</display-name>
<description>Receives xml files and saves them in file system</description>
<servlet>
<servlet-name>AcceptAndSaveTransmittedFile</servlet-name>
<servlet-class>servlets.AcceptAndSaveTransmittedFile</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AcceptAndSaveTransmittedFile</servlet-name>
<url-pattern>/processrequest</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>xml_input.html</welcome-file>
</welcome-file-list>
</web-app>
****************************************************************

After starting up tomcat and putting the URL
http://localhost:8080/hubtransmission/xml_input.html
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 ?


Thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410



Try:
<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
 
Don't get me started about those stupid light bulbs.
 
subject: cannot post to servlet