Hi
I'm a guy who hasn't written Java in a few years, and am trying to do the same thing in Java Servlets that I can currently do in Server-side Perl. Why?
Just trying to improve my skills. widen my horizons. improve my resume.
or something!
So, I'm writing Java from scratch (and borrowed snippets) ...
I also cross-posted this in the Java forum.
--------------------------------------------------------------
I get the following error when I compile the snippet below. If I comment out the line it complains about, it compiles cleanly.
I'd like to be able to call a subroutine... I mean, invoke a method... from within a doPost or doGet. All of the
examples I've seen put all the code within one method or they have methods that don't do anything.
I'd like to avoid having all of the print statements in one method. It seems to defeat the purpose of OO programming.
Thanks in advance for any help.
Pat
R:\SoftwareDev\MyJavaWork\Snippet1>javac -classpath "R:\SoftwareDev\Tomcat 4.1\c
ommon\lib\servlet.jar" Snippet1.java
Snippet1.java:31: cannot find symbol
symbol : variable output
location: class Snippet1
output.println(" Here's a method with more stuff ");
^
1 error
Here's the code
-----------------------------------------------------
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Snippet1 extends HttpServlet {
public void doGet (HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException {
String formText;
response.setContentType("text/html");
PrintWriter output=response.getWriter();
formText=request.getParameter("message");
if (formText==null || formText.length()==0) {
formText="This is my first servlet in quite a while <br> ";
}
output.println(formText);
}
public void morestuff() {
output.println(" Here's a method with more stuff "); //
//If I comment out the line above . .. I geta clean compile
}
}