Skip to content
Draft
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
18 changes: 18 additions & 0 deletions src/main/java/com/example/webapp/ClassWithInner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.webapp;

public class ClassWithInner {

private class Inner1 {
}

public ClassWithInner() {
final Inner1 inner1 = new Inner1();
System.out.println(inner1);
}

}


class Friendly {
final ClassWithInner classWithInner = new ClassWithInner();
}
2 changes: 1 addition & 1 deletion src/main/java/com/example/webapp/HelloServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
out.println("<title>Hello Servlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello from Servlet!</h1>");
out.println("<h1>Hello from Servlet Changed!</h1>");
out.println("<p>Request URI: " + request.getRequestURI() + "</p>");
out.println("<p>Servlet Path: " + request.getServletPath() + "</p>");
out.println("<p><a href='index.jsp'>Back to home</a></p>");
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/com/example/webapp/HelloServletNew.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.example.webapp;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
* A simple Hello World servlet
*/
public class HelloServletNew extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html;charset=UTF-8");

try (PrintWriter out = response.getWriter()) {
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Hello Servlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello from Servlet!</h1>");
out.println("<p>Request URI: " + request.getRequestURI() + "</p>");
out.println("<p>Servlet Path: " + request.getServletPath() + "</p>");
out.println("<p><a href='index.jsp'>Back to home</a></p>");
out.println("</body>");
out.println("</html>");
}
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">

<display-name>Maven Web Application</display-name>
<display-name>Maven Web Application Changed</display-name>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
Expand Down
26 changes: 26 additions & 0 deletions src/main/webapp/WEB-INF/webNew.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">

<display-name>Maven Web Application</display-name>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<!-- Sample Servlet Configuration -->
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>com.example.webapp.HelloServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>

</web-app>
2 changes: 1 addition & 1 deletion src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Maven Web Application</title>
<title>Maven Web Application Changed</title>
<style>
body {
font-family: Arial, sans-serif;
Expand Down
78 changes: 78 additions & 0 deletions src/main/webapp/indexNew.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.Date" %>
<!DOCTYPE html>
<html>
<head>
<title>Maven Web Application</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 50px auto;
padding: 20px;
background-color: #f5f5f5;
}
.container {
background-color: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
h1 {
color: #333;
}
.info {
background-color: #e8f4f8;
padding: 15px;
border-left: 4px solid #0066cc;
margin: 20px 0;
}
a {
color: #0066cc;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to Maven Web Application!</h1>

<div class="info">
<p><strong>Server Time:</strong> <%= new Date() %></p>
<p><strong>Session ID:</strong> <%= session.getId() %></p>
</div>

<h2>Quick Links</h2>
<ul>
<li><a href="hello">Hello Servlet</a> - A simple servlet example</li>
</ul>

<h2>Project Structure</h2>
<pre>
src/
├── main/
│ ├── java/
│ │ └── com/example/webapp/
│ │ └── HelloServlet.java
│ ├── resources/
│ └── webapp/
│ ├── WEB-INF/
│ │ └── web.xml
│ └── index.jsp
└── test/
├── java/
└── resources/
</pre>

<h2>Getting Started</h2>
<ul>
<li>Build: <code>mvn clean package</code></li>
<li>Run with Jetty: <code>mvn jetty:run</code></li>
<li>Deploy WAR to application server</li>
</ul>
</div>
</body>
</html>