I'm practicing Servlet/JSP following a demo on youtube. I have created the project with maven, using webapp archetype.
My servlet dependency in pom.xml file:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
My JSP file:
<%@ page import="model.Alien" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
Alien a1 = (Alien) request.getAttribute("alien");
out.println(a1);
%>
</body>
</html>
My project structure:
Alien is a simple POJO and GetAlienController has my Servlet which dispatches to showAlien.jsp. I didn't use web.xml, I'm using annotations.
The problem is, getAttribute() method of request is perfectly resolved but println() method of out is not resolved. Actually, none of the out methods are resolved. I tried copy servlet jar to webapp/lib and web-inf/lib directories also. Yet these didn't solve the problem.
In another project, I didn't use any Maven and used Intellij's Web Application prototype to create project. In this one, I didn't encounter a problem like this.
How can I solve this problem? I'm sure I'm putting servlet dependency to a wrong folder but still I couldn't solve it.
Please don't suggest me "don't write java code into JSP". It's just a demo. I'm trying to learn basics.
