[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

html and servlets

Posted on 2004-11-07
12
Medium Priority
?
247 Views
Last Modified: 2013-11-24
hi experts,
i have a servlet file called"ThreeParams.java " stored in the package  FileExchange.servlets. (in netbeans3.6)
i have a html file stored in FileExchange package.

The html form has three text fields and a submit button.

onthe html form, when i enter text and hit submit, the servlet should take the parametres and display them

..for some reason , the servlet is not displaying .

In the html form, I gave  html the <Form Action> as  <Form Action ="servlets/ThreeParams">

any advice greatly appreciated!

thanks

0
Comment
Question by:jaggernat
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12519813
Please post code
0
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 12519889
your form tag should probably be:

 <Form Action ="/servlet/ThreeParams">

or

 <Form Action ="servlet/ThreeParams">

check your servlet mapping for what is is named.
0
 
LVL 10

Author Comment

by:jaggernat
ID: 12519902
this is ThreeParams.java  stored in FileExchange.servlets package :

package FileExchange.servlets;

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

public class ThreeParams extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
//String title="Reading three request parametres";
//out.println(ServletUtilities.headWithTitle(title) );
out.println("<BODY BGCOLOR =\"#FDF5E6\">\n" +
//"<h1 ALIGN=CENTER>" +title + "<h1>\n"+
"<UL>\n"+
"<L1><b>param1</b>:"
+request.getParameter("PARAM1")+ "\n"+
"<L1><b>param2</b>:"
+request.getParameter("PARAM2")+ "\n"+
"<L1><b>param3</b>:"
+request.getParameter("PARAM3")+ "\n"+
"</UL>\n"+
"</body></html>");
}
}
-----------------------------------------------
This is the front end html (stored in FileExchange package)


<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Collecting three parametres </TITLE>
</head>
<BODY BGCOLOR ="#FDF5E6">
<h1 ALIGN="CENTER">COLLECTING THREE PARAMETRES </h1>
<Form ACTION="servlets/ThreeParams">
<!--<Form ACTION="http://localhost:8084/FileExchange/ThreeParams">-->
First Parameter :<INPUT TYPE="TEXT" NAME="PARAM1"> <BR>
Second Parameter :<INPUT TYPE="TEXT" NAME="PARAM2"> <BR>
Third Parameter :<INPUT TYPE="TEXT" NAME="PARAM3"> <BR>
<CENTER>
<INPUT TYPE ="SUBMIT">
</CENTER>
</FORM>
</BODY>
</HTML>


--------------------
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 92

Expert Comment

by:objects
ID: 12519939
Its nothing to with your code, you need to check your web.xml to see what name maps to the servlet.
0
 
LVL 10

Author Comment

by:jaggernat
ID: 12519945
this is my web.xml


<servlet>
    <servlet-name>ThreeParams</servlet-name>
    <servlet-class>FileExchange.servlets.ThreeParams</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>Hellowww</servlet-name>
    <servlet-class>FileExchange.servlets.Hellowww</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TokenServlet</servlet-name>
    <servlet-class>FileExchange.servlets.TokenServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>FileExchangeServlet</servlet-name>
    <url-pattern>/FileExchangeServlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>ThreeParams</servlet-name>
    <url-pattern>/ThreeParams</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Hellowww</servlet-name>
    <url-pattern>/Hellowww</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TokenServlet</servlet-name>
    <url-pattern>/TokenServlet</url-pattern>
  </servlet-mapping>
  <session-config>
    <session-timeout>
            30
        </session-timeout>
  </session-config>
  <welcome-file-list>
    <welcome-file>
            index.jsp
        </welcome-file>
    <welcome-file>
            index.html
        </welcome-file>
    <welcome-file>
            index.htm
        </welcome-file>
  </welcome-file-list>
</web-app>
---------------

0
 
LVL 92

Expert Comment

by:objects
ID: 12519949
try:

<Form ACTION="ThreeParams">

or

<Form ACTION="/ThreeParams">

depending on your apps context
0
 
LVL 10

Author Comment

by:jaggernat
ID: 12520019
>>>>>>>><Form ACTION="ThreeParams">

>>>>>>or

>>>>>>><Form ACTION="/ThreeParams">

it does not work..

I am working in netbeans3.6...and i put the java file "ThreeParams.java " in the package  -->FileExchange.servlets
an i put the HTML file in -->FileExchange package

0
 
LVL 28

Expert Comment

by:rrz
ID: 12520241
try
<Form ACTION="<%=request.getContextPath()%>/ThreeParams">
0
 
LVL 10

Author Comment

by:jaggernat
ID: 12527555
doesnt work..
should i store the html in the servlet package

plzz advice
0
 
LVL 92

Expert Comment

by:objects
ID: 12528399
check your server logs for errors
0
 
LVL 28

Expert Comment

by:rrz
ID: 12529432
>should i store the html in the servlet package    
No, it has to be in a  place that is accessable to browser.
So don't put it in  your context's WEB-INF directory.
Just put it in your context's root dirctory for testing.
0
 
LVL 10

Author Comment

by:jaggernat
ID: 12530247
>>>>>>>check your server logs for errors

i am using netbeans3.6 and i dont see anything in logs directory except a file called dummy which is not a text file.

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question