Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

localhost:8080/contato - Erro 404 - tomcat

Estou usando o tomcat versão 9.0.29 e não consegui abri a página contato.

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>br.com.alura.maven</groupId>
  <artifactId>lojaweb</artifactId>
  <packaging>war</packaging>
  <version>1.0.0-SNAPSHOT</version>
  <name>lojaweb Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <!-- adicionado 
    <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-servlet-api</artifactId>
            <version>9.0.29</version>
            <scope>provided</scope>        
    </dependency>
    -->

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>

     <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
    </dependency>

    <!-- final -->

  </dependencies>
  <build>
    <finalName>lojaweb</finalName>

    <plugins>
        <plugin>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-servlet-api</artifactId>
            <version>9.0.29</version>
            <configuration>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                    <webApp>
                        <contextPath>/loja</contextPath> 
                    </webApp>
            </configuration>

        </plugin>

         <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
         </plugin>
    </plugins>

  </build>
</project>

class ContatoServlet

@WebServlet(urlPatterns="/contato")
public class ContatoServlet extends HttpServlet{
    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        PrintWriter writer = resp.getWriter();
        writer.println("<html><h2>Entre em Contato</h2></html>");
        writer.close();
    }

}
1 resposta
solução!

Oi Aline, tudo bem?

Para esse curso, tenta rodar utilizando JDK 8 e Tomcat 8