As a starting point for web application development, I wanted to run JSP in a local environment. Since it took time to build the environment, I made a memo instead of a memorandum.
JSP?Servlet? Apparently, unlike PHP, Java is divided into JSP that draws the client side and Servlet that processes the server side.
Use Servlets and JSPs to create Java applications that run on the server side. Servlets and JSPs basically do the same thing, but Servlets are written like Java programs, while JSPs are written like a scripting language like PHP. Therefore, JSP is suitable for creating the screen display part, and it is suitable to create the part that works on the back end such as the connection with the database with the servlet. Introduction to Servlet / JSP
It's a different part from PHP. However, at this time of the year, I wonder if there are few opportunities to touch the JSP directly ... I have to read and study Around here (Web development with Java in 2015).
Apparently, Apache basically handles the Web content, but it seems that Tomcat's power is required to execute JSP / Java Servlet. XAMPP has prepared the area in good condition, so you can use it just by starting the service. As expected.
So let's generate a web page right away.
Start the "Tomcat" service from the XAMPP control panel.
From the web browser, enter "http : // localhost: 8080". If the above screen is displayed, you can confirm that Tomcat has started normally.
By default, "C: \ xampp \ tomcat \ webapps" is the root directory. I created a new "hellojsp" here.
Source code
<%@
page import="java.util.*"
contentType="text/html; charset=utf8"
%>
<!DOCTYPE html>
<html>
<head>
<title>JSP</title>
</head>
<body>
<%
java.util.Date nowTime = new java.util.Date();
%>
<h1>Hello, world! Now time is <strong><% out.print(nowTime); %></strong>.</h1>
</body>
</html>
Access the created "http : // localhost: 8080 / hellojsp / index.jsp". Confirm that the sample page is displayed.
It was an ordinary setting. Looking back now, where did I get hooked on my past self ... Understand the directory structure of Tomcat Dekitena Kattakara Nano Kanner (bar) This area (let's understand the directory structure of Tomcat) explains in detail. By the way, next is Java Servlet.
Recommended Posts