Installation of JavaStack
Create a folder with permission to write (in your user folder or in C:\temp). For example: C:\temp\Tomcat
Copy the following folders from C:\Programs\JavaStack\apache-tomcat-9.0.89 to C:\temp\Tomcat
Note: to reduce space, you can delete the folders docs and examples from webapps.
Create the file sj.bat in C:\temp\Tomcat
Execute the sj file:
C:\temp\Tomcat>sj
This will have defined the variables:
set CATALINA_BASE=C:\temp\Tomcat
set CATALINA_HOME=C:\Programs\JavaStack\apache-tomcat-9.0.89
set JAVA_HOME=C:\Programs\JavaStack\jdk1.8.0_131
Start Tomcat
Steps of “Installion of JavaStack”
C:\temp\Tomcat>sj
startup
Start the browser and write the address:
http://localhost:8082
shutdown
Create a Web page on the server
Steps of “Installation of JavaStack”
C:\temp\Tomcat>sj
Create a folder called ‘firstWeb’ in the webapps folder of the CATALINA_BASE folder.
Create the index.html file in the webapps\firstWeb folder with some html content
Start the Tomcat server as in step 4 of Start Tomcat:
startup
Create a Servlet
Steps of “Installation of JavaStack”
C:\temp\Tomcat>sj
CATALINA_BASE
└── webapps
└── Servlet1
└── WEB-INF
└── web.xml
└── classes
Create the HelloWorld.java file in the webapps\Servlet1\WEB-INF\classes folder. HelloWorld.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World");
}
}
javac HelloWorld.java
Create the web.xml file in C:\temp\Tomcat\webapps\Servlet1\WEB-INF folder:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
<servlet>
<servlet-name>primer</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>primer</servlet-name>
<url-pattern>/start</url-pattern>
</servlet-mapping>
</web-app>
Start the Tomcat server as in step 4 of Start Tomcat:
startup
To try other apps, download CS repository from https://github.com/nicolasserrano/CS and copy some webapps to your webapps