From 828ffa35841a585ddeeac9d934e3a4951e1702c0 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Mon, 28 Dec 2020 09:53:39 +0000
Subject: [PATCH] Von DefaultServlet auf HttpServlet umgestellt

---
 src/de/uhilger/wbx/web/TNServlet.java                 |    6 +++---
 src/de/uhilger/wbx/web/ViewServlet.java               |    4 ++--
 src/de/uhilger/wbx/web/MdServlet.java                 |    4 ++--
 src/de/uhilger/wbx/web/FilterServletOutputStream.java |   23 +++++++++--------------
 src/de/uhilger/wbx/web/TestServlet.java               |    2 +-
 5 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/src/de/uhilger/wbx/web/FilterServletOutputStream.java b/src/de/uhilger/wbx/web/FilterServletOutputStream.java
index 78ed352..791b7f7 100644
--- a/src/de/uhilger/wbx/web/FilterServletOutputStream.java
+++ b/src/de/uhilger/wbx/web/FilterServletOutputStream.java
@@ -22,7 +22,6 @@
 import java.io.OutputStream;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.WriteListener;
-//import javax.servlet.WriteListener;
 
 /**
  *
@@ -48,20 +47,16 @@
     stream.write(b,off,len); 
   } 
 
-    //@Override
-    public boolean isReady() {
-        // was ist hier zu tun...
-        return true;
-    }
+  //@Override
+  public boolean isReady() {
+      // was ist hier zu tun...
+      return true;
+  }
 
-    //@Override
-    //public void setWriteListener(WriteListener writeListener) {
-        // was ist hier zu tun..
-    //}
+  @Override
+  public void setWriteListener(WriteListener writeListener) {
+      //was ist hier zu tun..
+  }
 
-    @Override
-    public void setWriteListener(WriteListener wl) {
-        // TODO: Implement
-    }
  
 }
\ No newline at end of file
diff --git a/src/de/uhilger/wbx/web/MdServlet.java b/src/de/uhilger/wbx/web/MdServlet.java
index 919dc63..5f37d01 100644
--- a/src/de/uhilger/wbx/web/MdServlet.java
+++ b/src/de/uhilger/wbx/web/MdServlet.java
@@ -25,9 +25,9 @@
 import java.util.logging.Logger;
 import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import org.apache.catalina.servlets.DefaultServlet;
 
 /**
  * Das MdServlet fügt dem DefaultServlet von Tomcat 
@@ -43,7 +43,7 @@
  * 
  * TODO: Stylesheets dynamisch einbinden
  */
-public class MdServlet extends DefaultServlet {
+public class MdServlet extends HttpServlet {
   
   private static final Logger logger = Logger.getLogger(MdServlet.class.getName());
   private static final String HOME_CTX = "/home";
diff --git a/src/de/uhilger/wbx/web/TNServlet.java b/src/de/uhilger/wbx/web/TNServlet.java
index 9e58fa2..48a6703 100644
--- a/src/de/uhilger/wbx/web/TNServlet.java
+++ b/src/de/uhilger/wbx/web/TNServlet.java
@@ -23,10 +23,10 @@
 import java.net.URLDecoder;
 import java.util.logging.Logger;
 import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import net.coobird.thumbnailator.Thumbnails;
-import org.apache.catalina.servlets.DefaultServlet;
 
 /**
  * Mit dem TNServlet kann für eine Bilddatei eine 
@@ -36,7 +36,7 @@
  * Unterstuetzt werden die Varianten
  * 120 (_tn), 240 (_kl), 500 (_dd), 700 (_mt), 1200 (_gr)
  */
-public class TNServlet extends DefaultServlet {
+public class TNServlet extends HttpServlet {
   
   private static final Logger logger = Logger.getLogger(TNServlet.class.getName());
   
@@ -93,7 +93,7 @@
     // --- Logausgabe Ende
         
     if(uriStr.endsWith(JPG) || uriStr.endsWith(JPEG) || uriStr.endsWith(PNG)) {
-      File dir = new File(request.getServletContext().getRealPath("/"));
+      File dir = new File(request.getSession().getServletContext().getRealPath("/"));
       String suburiStr = uriStr.substring(request.getContextPath().length());
       File imgfile = new File(dir, suburiStr);    
       if(uriStr.contains(TN)) {
diff --git a/src/de/uhilger/wbx/web/TestServlet.java b/src/de/uhilger/wbx/web/TestServlet.java
index 9580778..91eeccf 100644
--- a/src/de/uhilger/wbx/web/TestServlet.java
+++ b/src/de/uhilger/wbx/web/TestServlet.java
@@ -52,7 +52,7 @@
       out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
       
       // hier kommt veraenderlicher Inhalt
-      ServletContext ctx = request.getServletContext();
+      ServletContext ctx = request.getSession().getServletContext();
       Object o = ctx.getAttribute("filebase");
       String base;
       if(o instanceof String) {
diff --git a/src/de/uhilger/wbx/web/ViewServlet.java b/src/de/uhilger/wbx/web/ViewServlet.java
index f4b7126..0ef8485 100644
--- a/src/de/uhilger/wbx/web/ViewServlet.java
+++ b/src/de/uhilger/wbx/web/ViewServlet.java
@@ -26,9 +26,9 @@
 import javax.naming.NamingException;
 import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import org.apache.catalina.servlets.DefaultServlet;
 
 /**
  * Das ViewServlet f&uuml;gt dem DefaultServlet von Tomcat 
@@ -39,7 +39,7 @@
  * 
  * TODO: Stylesheets dynamisch einbinden
  */
-public class ViewServlet extends DefaultServlet {
+public class ViewServlet extends HttpServlet {
   
   private static final Logger logger = Logger.getLogger(ViewServlet.class.getName());
   private static final String HOME_CTX = "/home";

--
Gitblit v1.9.3