Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet

 
Lucky Singh
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 405
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At line
if(if(selection.equals("subtract"))
getting a Null Pointer Exception.
Without this, form loads properly.
Any ideas?
 
Bhaskar Reddy
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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\"
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic