Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Porting single servlet example to NetBeans 6.1

Reply
Thread Tools

Porting single servlet example to NetBeans 6.1

 
 
Kurt
Guest
Posts: n/a
 
      07-20-2008
Greetings;



Specifics:

OS: Win XP PRO
App Serv: Tomcat 5.5
Netbeans: 6.1

Issue: I am trying to port a simple single servlet from the first
example in Head First Servlets and JSP 2nd Edition to Netbeans 6.1.

This example works fine when I deploy it manually under Tomcat.
However, I am getting a 404 error looking for /Beer-v1/selectBeer.do
when I try to run the version built and deployed with Netbeans.


Working structure under tomcat\webapps\Beer-v1 directory

WEB-INF
†€€€classes
 „€€€com
 „€€€example
 †€€€model
 „€€€web
„€€€lib


Files present;

\Beer-v1\form.html
\Beer-v1\result.jsp
\Beer-v1\WEB-INF\web.xml
\Beer-v1\WEB-INF\classes\com\example\web\BeerSelect.class

Non Working directory under Netbeans:

C:\java\projects\Beer-v1>
†€€€build
 „€€€web
 †€€€META-INF
 „€€€WEB-INF
 „€€€classes
 „€€€com
 „€€€example
 „€€€web
†€€€dist
†€€€nbproject
 „€€€private
†€€€src
 †€€€conf
 „€€€java
 „€€€com
 „€€€example
 „€€€web
†€€€test
„€€€web
†€€€META-INF
„€€€WEB-INF


File present:

\Beer-v1\build\web\index.html
\Beer-v1\build\web\META-INF\context.xml
\Beer-v1\build\web\META-INF\MANIFEST.MF
\Beer-v1\build\web\WEB-INF\web.xml
\Beer-v1\build\web\WEB-INF\classes\com\example\web\BeerSelect.class
\Beer-v1\build\web\WEB-INF\classes\com\example\web\result.jsp
\Beer-v1\dist\Beer-v1.war
\Beer-v1\nbproject\ant-deploy.xml
\Beer-v1\nbproject\build-impl.xml
\Beer-v1\nbproject\genfiles.properties
\Beer-v1\nbproject\private
\Beer-v1\nbproject\project.properties
\Beer-v1\nbproject\project.xml
\Beer-v1\nbproject\private\private.properties
\Beer-v1\src\conf\MANIFEST.MF
\Beer-v1\src\java\com
\Beer-v1\src\java\com\example\web\BeerSelect.java
\Beer-v1\src\java\com\example\web\result.jsp
\Beer-v1\web\index.html
\Beer-v1\web\META-INF\context.xml
\Beer-v1\web\WEB-INF\web.xml


Contents of web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>


Contents of index.html and form.html (They are the same, just two
different names so I can test the manual build and nb build):


<html>
<body>
<h1 align="center">Beer Selection Page</h1>
<form method="POST" action="selectBeer.do">
Select Beer Characteristics<p>
Color:
<select name="color" size="1">
<option value="light"> light </option>
<option value="amber"> amber</option>
<option value="brown"> brown </option>
<option value="dark"> dark </option>
</select>
<br><br>
<center>
<input type="SUBMIT">
</center>
</form>
</body>
</html>


Source to servlet BeerSelect.java


package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class BeerSelect extends HttpServlet

{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice<br>");
String c = request.getParameter("color");
out.println("<br>Got beer color " + c);

}
}



Any ideas?
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      07-21-2008
On Jul 20, 1:28*pm, Kurt <(E-Mail Removed)> wrote:
> Greetings;
>
> Specifics:
>
> OS: Win XP PRO
> App Serv: Tomcat 5.5
> Netbeans: 6.1
>
> Issue: *I am trying to port a simple single servlet from the first
> example in Head First Servlets and JSP 2nd Edition to Netbeans 6.1.
>
> This example works fine when I deploy it manually under Tomcat.
> However, I am getting a 404 error looking for /Beer-v1/selectBeer.do
> when I try to run the version built and deployed with Netbeans.


By what steps exactly are you telling NetBeans to deploy this app to
the server, as opposed to simply building the app into the build/ and
dist/ subdirectories?

Are you running the Web app using NetBeans' "run" command, else how?

--
Lew
Two questions, which you have not answered unless you provided two
answers.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Porting a JSF based application from Netbeans 6.1 to Eclipse Ganymede3.4 Rakesh Java 7 07-03-2008 09:01 AM
Eclipse vs. Netbeans. Netbeans is winning me over almost at first glance. Thomas G. Marshall Java 2 10-16-2006 02:54 AM
[NETBEANS] [EVALUATION] - E12 - The NetBeans Open Source Lie Ilias Lazaridis Java 0 12-12-2004 02:41 PM
Building a GUI using NetBeans platform (not Netbeans IDE !) Pimousse Java 2 04-21-2004 07:22 AM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM



Advertisments