There are a lot of animations on the HDD, but it is troublesome to connect the HDD to a computer and watch it, so let's make it visible from the browser.
Since the place where the animation is saved is not a NAS but just an HDD, it is assumed that the HDD is a NAS using Raspberry Pi. The procedure for turning an HDD into a NAS is not shown here.
HDD(NAS)Location
/mnt/hdd/HD-V3/Anime/
The procedure on this site is super easy to understand, so follow here. Raspberry Pi Tomcat-8 environment settings
If you do the basics as written, it will work smoothly. However, if you do it with wget in exactly the same way, it will not work because apache-tomcat-8.5.4.tar.gz is no longer available. Since 8.5.31 was up to date, I think you should download apache-tomcat-8.5.31.tar.gz on Windows and send it to Raspberry Pi with scp or something. It seemed like I was using gedit (?) To edit the script, but it was like that, so I wrote the script in my favorite nano. If you follow the steps in the link above, tomcat will be in / usr / local / tomcat. This time I will proceed with the story with tomcat here.
location of tomcat
/usr/local/tomcat/
Work is done under a folder called workspace. It seems that tomcat specifies the name of the folder to put the class file of the web application. If you create an app with a hierarchy based on it, the hierarchy will be as follows. Originally, this time, it seems that I will create a folder of my own application under tomcat / webapps /, but since the NAS is on a higher layer, I do not want to create a web application under webapps. That's why the workspace is placed on the HDD.
workspace location
/mnt/hdd/HD-V3/Anime/workspace/
Since the workspace is not under webapps, I need to tell tomcat. Write as follows. The name of the file must be the name of the directory. (There seems to be a way to write it in server.xml, but it didn't work.)
/usr/local/tomcat/conf/Catalina/localhost/workspace.xml
<Context path="/workspace" docBase="/mnt/hdd/HD-V3/Anime/workspace" />
Write the page structure of the workspace.
/mnt/hdd/HD-V3/Anime/workspace/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>cookie1</servlet-name>
<servlet-class>cookie1</servlet-class>
</servlet>
<servlet>
<servlet-name>cookie2</servlet-name>
<servlet-class>cookie2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
cookie1
</servlet-name>
<url-pattern>
/servlet/cookie1
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
cookie2
</servlet-name>
<url-pattern>
/servlet/cookie2
</url-pattern>
</servlet-mapping>
</web-app>
I originally planned to use cookies, so this name is used, but I haven't used it in the program. cookie1.java Get the file name list in / mnt / hdd / HD-V3 / anime / workspace / anime /, add it to the pull-down menu, select one title, and transition to cookie2.java.
cookie1.java
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.File;
public class cookie1 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html; charset=utf-8");
PrintWriter out = response.getWriter();
request.setCharacterEncoding("UTF-8");
out.println("<html><head>");
out.println("<title>cookie1</title>");
out.println("</head><body>");
out.println("<h1>Wiki Anime DB</h1><hr>");
String root="/mnt/hdd/HD-V3/Anime/workspace/anime/";
File dir=new File(root);
File[] list=dir.listFiles();
out.println("Number of titles:"+list.length+"<br>");
out.println("<form action=\"/workspace/servlet/cookie2\" method=\"GET\">");
out.println("name: <input type=\"text\" name=\"name\" size=32>");
out.println("<br>");
out.println("<input type=\"submit\" value=\"Code generation\">");
out.println("<br>");
out.println("<select name=\"anime\">");
for(int i=0;i<list.length;i++){
String dst=list[i].toString();
dst=dst.replace(root,"");
out.println("<option value=\""+dst+"\">"+dst+"</option>");
}
out.println("<select>");
out.println("</form>");
out.println("</body></html>");
}
}
cookie2.java Based on the animation title received from cookie1.java, only the files with the extension .mp4 | .MP4 in the hierarchy one level below that folder are output by sandwiching them with video tags.
cookie2.java
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.File;
public class cookie2 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html; charset=utf-8");
PrintWriter out = response.getWriter();
request.setCharacterEncoding("UTF-8");
String aname=request.getParameter("anime");
String eaname=URLDecoder.decode(aname,"UTF-8");
String root="../anime/";
String root_t="/mnt/hdd/HD-V3/Anime/workspace/anime/";
out.println("<html><head>");
out.println("<title>cookie2</title>");
out.println("</head><body>");
out.println("<h1>"+eaname+"</h1><hr>");
out.println("Selected anime folder="+eaname+"<br>");
out.println("<form action=\"/workspace/servlet/cookie1\" method=\"GET\">");
out.println("<input type=\"submit\" value=\"Return\">");
out.println("</form>");
File dir=new File(root_t+eaname);
File[] list=dir.listFiles();
out.println("File="+list.length+"<br>");
for(int i=0;i<list.length;i++){
String dst=list[i].toString();
dst=dst.replace(root_t+eaname+"/", "");
if(dst.indexOf(".mp4")!=-1 || dst.indexOf(".MP4")!=-1){
dst=root+eaname+"/"+dst;
out.println(dst+"<br>");
out.println("<video src=\""+dst+"\" preload=\"none\" controls></video><br>");
}
}
out.println("</body></html>");
}
}
You have to compile by adding servlet-api.jar with the classpath option.
/mnt/hdd/HD-V3/Anime/workspace/WEB-INF/classes/
$ javac -classpath "/usr/local/tomcat/lib/servlet-api.jar" cookie1.java
$ javac -classpath "/usr/local/tomcat/lib/servlet-api.jar" cookie2.java
Caution Initially, compilation failed because /usr/local/tomcat/lib/servlet-api.jar does not have permission.
Authorization
$sudo chmod 755 /usr/local/tomcat/lib/servlet-api.jar
I granted the permissions and then compiled it and it worked.
python
$ sudo /etc/init.d/tomcat start
But for the time being, ZOY allows you to watch the animation on the HDD more comfortably from your smartphone.