Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help for import javax.servlet.* on JBuilder 8 Ent

 
Mirai Chelean
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, thank you for visiting my SOS. I am absolute a java servlet beginner and just start learn via using JBuilder 8 Ent with Tomcat 5.0.28. I look for some helps from java servlet experienced. While i'm coding for the very first of my java servlet programe, "HelloServlet3.java" on JBuilder i got this error. Which i also no idea since i'm follow exactly the same from a tutorial instruction.

"HelloServlet3.java": Error #: 704 : cannot access directory javax\servlet at line 4, column 1
"HelloServlet3.java": Error #: 300 : class HttpServlet not found in class hello.HelloServlet3 at line 16, column 36

Here is the codes for "HelloServlet3.java"


package hello;

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

/** Simple servlet for testing the use of packages
* and utilities from the same package.
* <P>
* Taken from Core Servlets and JavaServer Pages 2nd Edition
* from Prentice Hall and Sun Microsystems Press,
* http://www.coreservlets.com/.
* © 2003 Marty Hall; may be freely used or adapted.
*/

public class HelloServlet3 extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Hello (3)";
out.println(ServletUtilities.headWithTitle(title) +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>" + title + "</H1>\n" +
"</BODY></HTML>");
}
}

My Question is, is it JBuilder don have the build-in Servlet? Am i need to install the so-call directory Javax/servlet by myself? If thats the way, can somebody help me to give me the instructions for it.

Thank you in advance.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to add servlet-api.jar to your classpath.
It can be found in {tomcat intallation}/common/lib.

You'll have to check with JBuilder's documentation if you don't know how to add libraries to your classpath.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which feature you'll likely find under "tools->configure->libraries" (at least that's where it is in JB2005).
But the servlet library should already be available as you have the enterprise version so all you need to do is add it to the required libraries for your project from the project properties dialog. In JB2005 you can do so from the "paths" tab, "required libraries" subtab.

It's as Ben pointed out explained quite well in the documentation too.
 
Mirai Chelean
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to you Ben and Jeroen, ok I'll read the documentation first.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic