diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 127dfcc..2ff8523 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ /build -/WebContent/WEB-INF/web.xml -/WebContent/WEB-INF/web_debug.xml -/WebContent/WEB-INF/web_server.xml /WebContent/WEB-INF/lib/Zutil.jar \ No newline at end of file diff --git a/WebContent/WEB-INF/context.sample.xml b/WebContent/WEB-INF/context.sample.xml new file mode 100755 index 0000000..9c44dd1 --- /dev/null +++ b/WebContent/WEB-INF/context.sample.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/WebContent/WEB-INF/web_sample.xml b/WebContent/WEB-INF/web.xml old mode 100644 new mode 100755 similarity index 62% rename from WebContent/WEB-INF/web_sample.xml rename to WebContent/WEB-INF/web.xml index 277e27c..6a58f89 --- a/WebContent/WEB-INF/web_sample.xml +++ b/WebContent/WEB-INF/web.xml @@ -1,91 +1,71 @@ - - - Zallery - - - gallery - - - - Zallery - zall.Zallery - - WEBSITE_NAME - Gallery - - - WEBSITE_URL - http://example.com/Zallery/ - - - SMTP_HOST - 127.0.0.1 - - - THEME - - - - DATA_PATH - C:\\data - - 1 - - - Zallery - /gallery - /media - /slideshow - /login - /logout - /upload - /profile - /users - /register - - - - Content - zall.ZalleryContent - - - Content - /content - - - - Ajax - zall.ZalleryAjax - - - Ajax - /ajax - - - - Upload - zall.UploadServlet - - TEMP_PATH - C:\\temp - - - ALLOWED_EXTENSIONS - png,jpg,jpeg,gif,tif,bmp,avi,wmv,mov,mp4,mpeg,flv,m4v,divx,xvid - - - - Upload - /uploadserv - - - - transcoder - zall.ZalleryTranscoder - 1 - - - - gallery - + + + Zallery + + + + Zallery + zall.Zallery + 1 + + + Zallery + /gallery + /media + /slideshow + /login + /logout + /upload + /profile + /users + /register + + + + Content + zall.ZalleryContent + + + Content + /content + + + + Ajax + zall.ZalleryAjax + + + Ajax + /ajax + + + + Upload + zall.UploadServlet + + TEMP_PATH + SYSTEM + + + ALLOWED_EXTENSIONS + png,jpg,jpeg,gif,tif,bmp,avi,wmv,mov,mp4,mpeg,flv,m4v,divx,xvid + + + + Upload + /uploadserv + + + + transcoder + zall.ZalleryTranscoder + 1 + + + + gallery + \ No newline at end of file diff --git a/src/zall/Zallery.java b/src/zall/Zallery.java old mode 100644 new mode 100755 index 65ad6f2..5667864 --- a/src/zall/Zallery.java +++ b/src/zall/Zallery.java @@ -6,6 +6,9 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletConfig; import javax.servlet.ServletException; @@ -31,7 +34,6 @@ public class Zallery extends HttpServlet{ public static String WEBSITE_NAME = "Example.com"; public static String WEBSITE_URL = "http://example.com"; - public static String THEME = ""; public static String ROOT_PATH = ""; public static String DATA_PATH = ""; @@ -41,30 +43,25 @@ public class Zallery extends HttpServlet{ *
- WEBSITE_URL *
- SMTP_HOST *
- DATA_PATH - *
- THEME - *
- FB_APPID - *
- FB_APPSEC */ public void init(ServletConfig config) throws ServletException { super.init(config); + // java:comp/env ROOT_PATH = config.getServletContext().getRealPath("/"); - if( config.getInitParameter("WEBSITE_NAME") != null ) - WEBSITE_NAME = config.getInitParameter("WEBSITE_NAME"); - if( config.getInitParameter("WEBSITE_URL") != null ){ - WEBSITE_URL = config.getInitParameter("WEBSITE_URL"); - if( WEBSITE_URL.charAt(WEBSITE_URL.length()-1) != '/') - WEBSITE_URL += "/"; - } - if( config.getInitParameter("SMTP_HOST") != null ) - Email.setServer( config.getInitParameter("SMTP_HOST") ); - if( config.getInitParameter("DATA_PATH") != null ) - DATA_PATH = config.getInitParameter("DATA_PATH"); - else - throw new ServletException("Missing DATA_PATH parameter!"); - if( config.getInitParameter("THEME") != null ) - THEME = config.getInitParameter("THEME"); - LogUtil.setLevel("zall", Level.FINEST); - //LogUtil.setLevel("zutil", Level.FINEST); + try { + Context context = new InitialContext(); + WEBSITE_NAME = (String)context.lookup("java:comp/env/WEBSITE_NAME"); + WEBSITE_URL = (String)context.lookup("java:comp/env/WEBSITE_URL"); + if( WEBSITE_URL.charAt(WEBSITE_URL.length()-1) != '/') + WEBSITE_URL += "/"; + Email.setServer( (String)context.lookup("java:comp/env/SMTP_HOST") ); + DATA_PATH = (String)context.lookup("java:comp/env/DATA_PATH"); + + LogUtil.setLevel("zall", Level.FINEST); + //LogUtil.setLevel("zutil", Level.FINEST); + } catch (NamingException e) { + throw new ServletException(e); + } } public void destroy(){ @@ -272,7 +269,7 @@ public class Zallery extends HttpServlet{ } protected void include(String url, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ - RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(THEME+"/"+url); + RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/"+url); if (dispatcher != null) dispatcher.include(request, response); }