Reputation: 266950
Just creating my first IntelliJ web application that runs on tomcat.
The project ran fine, and it rendered the index.jsp just fine.
How come the index.jsp rendered even though the web.xml doesn't have a reference to it btw? Does it first look for psychical files (.jsp's), if present, it executes them? Or is web.xml just for servlets?
The real issue was I created a TestServlet in my /src folder, and it can't seem to find the javax.servlet jar:
package javax.servlet.http does not exist
Reference:
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<display-name>Test1</display-name>
<servlet-name>TestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
</web-app>
TestServlet.java:
import java.io.IOException;
package hello_world.Servlets
/**
* Created by IntelliJ IDEA.
* User: snad
* Date: Oct 29, 2011
* Time: 9:19:27 AM
* To change this template use File | Settings | File Templates.
*/
public class TestServlet extends javax.servlet.http.HttpServlet {
protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
}
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
}
}
Upvotes: 4
Views: 19863
Reputation: 597036
test.TestServlet
Upvotes: 4