• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FIRST EXAMPLE NOT WORKING..!!

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have made the web.xml file and the form.html file.But I am not able to open up the html form from the browser using http://localhost:8080/Beer-v1/form.html.

My folders are as follows

HTML FILE ----> C:\Program Files\Java\apache-tomcat-7.0.6\webapps\Beer-v1\form.html
WEB-INF FILE ----> C:\Program Files\Java\apache-tomcat-7.0.6\webapps\Beer-v1\WEB-INF

When I directly click on the html file is it working but when I start the tomcat and then open http://localhost:8080/Beer-v1/form.html address, it is showing an error message "The requested resource (/Beer-v1/form.html) is not available."

Were exactly is the error ??
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
where is your web.xml? and what is in it?

Regards,
Frits
 
Shagun Bhardwaj
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Fritz for replying to my query but I have managed to correct it.
I was using a wrong directory for deployment..

I have a new query now.

I have the form.html page up and running.But when I select the color and hit 'Submit' on the page,it gives me a error message HTTP Status 405 -"HTTP method GET is not supported by this URL"

Html file

<html><body>
<h1 align="center">Shri Ram Beer Selection Page <h1/>
<form methd="POST"
action="SelectBeer.do">
Select beer characterstics<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>
--------------------------------------------------------------------------------------------------------

SelectBeer.java file

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);
}
}
---------------------------------------------------------------------------------------------------------------

xml file

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<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>
---------------------------------------------------------------------------------------------------------------


I hope you can help me on this one too.


Thanking you
Shagun
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as you have misspelled the method in:

<form methd="POST" action="SelectBeer.do">


It sends a GET to the server and in your Servlet it looks for the method doGet(), which you haven't implemented.

Change it to method="POST" and it should work.

Regards,
Frits
 
Shagun Bhardwaj
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much. It is working..!!
Thanks a lot

Regards
Shagun
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic