Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<configuration>
<webXml>src/main/webapp/web.xml</webXml>
</configuration>
<version>3.4.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/mate/controller/IndexController.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
package mate.controller;

import java.io.IOException;
import java.time.LocalTime;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mate.dao.MyCoolResource;

public class IndexController extends HttpServlet {
private MyCoolResource myResource;
//TODO: implement

@Override
public void init() throws ServletException {
myResource = MyCoolResource.openResource();
}

@Override
protected void doGet(HttpServletRequest req,
HttpServletResponse resp) throws ServletException, IOException {
myResource.write(LocalTime.now().toString());
req.getRequestDispatcher("/WEB-INF/views/index.jsp")
.forward(req, resp);
}

@Override
public void destroy() {
myResource.close();
}
}
18 changes: 18 additions & 0 deletions src/main/webapp/WEB-INF/views/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<%--
Created by IntelliJ IDEA.
User: toxauz
Date: 26.07.2023
Time: 17:43
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>indexPage</title>
</head>
<body>

<h2>"Information written to our resource"</h2>

</body>
</html>