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

HTTP ERROR 404

HTTP ERROR 404 Problem accessing /loja/contato. Reason:

Not Found

link - http://localhost:8080/loja/contato

<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>

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

  </dependencies>
  <build>


    <finalName>lojaweb</finalName>
    <plugins>
            <plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-manven-plugin</artifactId>
    <version>9.3.7.v2016115</version>
  <configuration>
    <scanIntervalSeconds>10</scanIntervalSeconds>
        <webApp>
<!--             <contextPath>/loja</contextPath> -->
        </webApp>
    </configuration>
</plugin>

             pom.xml 

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

  </build>
  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
</project>

ContatoServlet.java

@WebServlet(urlPatterns={"/contato"})
public class ContatoServlet extends HttpServlet{

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

Não consigo exibir a pagina no navegador, me ajudem por favor!

1 resposta
solução!

Olá Jean!

Olhando seu código, o contexto está comentado:

<webApp>
    <!--<contextPath>/loja</contextPath>-->
</webApp>

Tenta descomentar e acessa essa mesma URL pra ver se funciona.

Aguardo seu retorno! ^^

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software