ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
I have installed sun-java6 on debian lenny.
I took a program ( using servlet ) from a book, so I suppose it runs correctly, I tried it on my PC using sun-java6. Does it have another name?
Other programs, with (swing, applet ...), run correcly.
I searched servlet class in javax, I didn't find it
the error is at the import javax.servlet.*; import javax.servlet.http.*;
here is the example
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CalculPerimeter extends HttpServlet {
public void doGet( HttpServletRequest req, HttpServletResponse rep)
throws IOException, ServletException {
rep.setContentType("text/html");
PrintWriter pw = rep.getWriter();
pw.println("<html>");
pw.println("<head>");
pw.println("<title> Just a servlet </title>");
pw.println("</head>");
pw.println("<body bgcolor='white'>");
if (req.getParameter("ray") == null) {
pw.print("<font size=+1> ");
pw.println(" need to know the value of the ray!</font>");
}
else {
int tmp=Integer.parseInt(req.getParameter("ray"));
Circle C = new Circle(0, 0, tmp);
double p = C.perimeter();
pw.println("The ray is "+tmp+"perimeter "+ p);
}
pw.println("</body>");
pw.println("</html>");
}
}
The Circle class is of couse defined.
Thanks for help
Hi,
I have installed sun-java6 on debian lenny.
I took a program ( using servlet ) from a book, so I suppose it runs correctly, I tried it on my PC using sun-java6. Does it have another name?
Other programs, with (swing, applet ...), run correcly.
I searched servlet class in javax, I didn't find it
the error is at the import javax.servlet.*; import javax.servlet.http.*;
here is the example
Code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CalculPerimeter extends HttpServlet {
public void doGet( HttpServletRequest req, HttpServletResponse rep)
throws IOException, ServletException {
rep.setContentType("text/html");
PrintWriter pw = rep.getWriter();
pw.println("<html>");
pw.println("<head>");
pw.println("<title> Just a servlet </title>");
pw.println("</head>");
pw.println("<body bgcolor='white'>");
if (req.getParameter("ray") == null) {
pw.print("<font size=+1> ");
pw.println(" need to know the value of the ray!</font>");
}
else {
int tmp=Integer.parseInt(req.getParameter("ray"));
Circle C = new Circle(0, 0, tmp);
double p = C.perimeter();
pw.println("The ray is "+tmp+"perimeter "+ p);
}
pw.println("</body>");
pw.println("</html>");
}
}
The Circle class is of couse defined.
Thanks for help
You will need to add servlet.jar to your classpath. If you download apache-tomcat, you will have that jar within the "lib" folder of Tomcat.
Personally, I would recommend you to download "Eclipse IDE for Java EE Developers", so you don't have to worry about those things . Netbeans actually even helps you to install Tomcat and/or Glassfish during installation. A big help indeed. I know recommending an IDE sounds overkill, but Servlets and JSP are a complex matter. It gets even more tough when you put in some frameworks like Hibernate or Struts. You will need an IDE, so you better off start with one, IMHO.
P.S: in the future, when posting code, please use the <code> tags as I just did. Makes it much easier on the eyes
Last edited by Mega Man X; 10-19-2008 at 06:11 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.