$ java -version java version "1.6.0_45" Java(TM) SE Runtime
Environment (build 1.6.0_45-b06-451-10M4406) Java HotSpot(TM) 64-Bit
Server VM (build 20.45-b01-451, mixed mode)
Tomcat version: 7.0.40
I'm following the beginning servlet/jsp tutorial here:
https://stackoverflow.com/tags/servlets/info
and I am getting this error:
HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/functions cannot be resolved in either web.xml or the jar files deployed with this application
Which looks like it's coming from the .jsp file which begins with this line:
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html lang="en">
I compiled my servlet like this:
~/java_programs/modernServlet$ javac -cp /Library/Tomcat/lib/servlet-api.jar -d classes src/com/example/controller/HelloServlet.java
And then I copied that file to the same directory structure under WEB-INF classes in the Tomcat directory. Is there some other jar file I should be including in the classpath?
====
Okay, I downloaded and copied the jstl jar to Tomcat's lib directory, and and now I get all kinds of compile errors:
$ javac -cp "/Library/Tomcat/lib/servlet-api.jar;/Library/Tomcat/lib/jstl-1.2.jar" -d classes src/com/example/controller/HelloServlet.java
src/com/example/controller/HelloServlet.java:7: package javax.servlet does not exist
import javax.servlet.ServletException;
^
src/com/example/controller/HelloServlet.java:8: package javax.servlet.annotation does not exist
import javax.servlet.annotation.WebServlet;
^
src/com/example/controller/HelloServlet.java:9: package javax.servlet.http does not exist
import javax.servlet.http.HttpServlet;
^
src/com/example/controller/HelloServlet.java:10: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletRequest;
^
src/com/example/controller/HelloServlet.java:11: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletResponse;
^
src/com/example/controller/HelloServlet.java:14: cannot find symbol
symbol: class HttpServlet
public class HelloServlet extends HttpServlet {
^
src/com/example/controller/HelloServlet.java:13: cannot find symbol
symbol: class WebServlet
@WebServlet("/hello")
^
src/com/example/controller/HelloServlet.java:17: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.controller.HelloServlet
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
^
src/com/example/controller/HelloServlet.java:17: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.controller.HelloServlet
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
^
src/com/example/controller/HelloServlet.java:17: cannot find symbol
symbol : class ServletException
location: class com.example.controller.HelloServlet
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
^
src/com/example/controller/HelloServlet.java:23: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.controller.HelloServlet
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
^
src/com/example/controller/HelloServlet.java:23: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.controller.HelloServlet
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
^
src/com/example/controller/HelloServlet.java:23: cannot find symbol
symbol : class ServletException
location: class com.example.controller.HelloServlet
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
^
src/com/example/controller/HelloServlet.java:16: method does not override or implement a method from a supertype
@Override
^
src/com/example/controller/HelloServlet.java:22: method does not override or implement a method from a supertype
@Override
^
15 errors