JollyRoger
JollyRoger

Reputation: 837

Why can not reach my web application?

I am trying to create a simple web application with using Maven which is just connects to mssql server and my IDE is IntelliJ. Here is my index.jsp file:

<%@ page import="java.io.IOException" %>
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
    try{
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        Connection connection = 
DriverManager.getConnection("jdbc:sqlServer://127.0.0.1;         
databaseName=database password=passwordd");
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select * from tablo 
where id = 10");
        while(resultSet.next()){
            out.println(resultSet.getArray(0) + " " + resultSet.getArray(1));
        }
    }catch(IOException e){
        e.printStackTrace();
    }catch(SQLException e){
        e.printStackTrace();
    }catch(ClassNotFoundException e){
        e.printStackTrace();
    }
    %>
</body>
</html>

I did not change the web.xml file so it is just empty. My problem is that when I run the web application on tomcat server, I got HTTP Status 404 - Not Found error. The URL is "http://localhost:8080/". And I also tried http://localhost:8080/index.jsp and "http://localhost:8080/webapp/index.jsp" but result is same. Feel like I did not gave enough information, it is just because I am new at creating web applications. Where am I doing wrong?

Edit:

I just change the way that I deploy my web project and worked. It was mywebapp: war and now mywebapp: war exploded. Why it worked now? What is the difference between them or pointing my project folder? –

Upvotes: 0

Views: 148

Answers (1)

JollyRoger
JollyRoger

Reputation: 837

My problem was about the way I deployed my web project. When I deploy it as MyWebApp: war exploded it worked perfectly. Hope it will help someone.

Upvotes: 1

Related Questions