aspose file tools*
The moose likes Servlets and the fly likes Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet" Watch "Servlet" New topic
Author

Servlet

Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
Hi,
Can you tell mw what is wrong here?
out.println("<TR><TD><INPUT TYPE=radio NAME=abc VALUE=\"subract\">Subtract Numbers</TD></TR>");
String selection = req.getParameter("abc");
if(selection.equals("subtract"))
// subtract numbers.
I have doubts about the inverted comas in the above 3 statements.
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
I do not see anything wrong with the statements(syntax wise). Are you generating an error message? Are you talking about the escape character("\")?
Please elaborate.
Craig.
Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
Ok, i just checked and syntax seems all ok to me.
I want to process this form, should I have a doGet() to display the form and doPost() to process it. I want to do it within the same doGet(). can it be done within the same method?
On subtracting the numbers my servlet should display this form again.
public class AServlet
{
public void doGet()
// display form.
//display response + empty form.
}

Is the syntax for the form ok?
out.println("<FORM METHOD = \"get\" ACTION = \"AServlet\" >");
Why does the System.out.println() not work with servlets?
How do I make it work so that its easy for me to debug.
Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
At line
if(if(selection.equals("subtract"))
getting a Null Pointer Exception.
Without this, form loads properly.
Any ideas?
Bhaskar Reddy
Ranch Hand

Joined: Dec 17, 2002
Posts: 52

out.println("<TR><TD><INPUT TYPE=radio NAME=abc VALUE=\"subract\">Subtract Numbers</TD></TR>");

Can you try with
VALUE='subtract'
instead of
VALUE=\"subract\"
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlet