How to Enable SSI (Server Side Includes) on Tomcat 7 at Ubuntu? - html

How can I enable SSI on Tomcat 7?.
I follow the directions however it doesn't work. I changed my main file's extension from html to shtml (not imported one) and unquoted that lines at web.xml:
<servlet>
<servlet-name>ssi</servlet-name>
<servlet-class>
org.apache.catalina.ssi.SSIServlet
</servlet-class>
<init-param>
<param-name>buffered</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>expires</param-name>
<param-value>666</param-value>
</init-param>
<init-param>
<param-name>isVirtualWebappRelative</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>4</load-on-startup>
</servlet>
What do do more, where is the wrong?

You also need to uncomment the SSI servlet mapping in web.xml
<servlet-mapping>
<servlet-name>ssi</servlet-name>
<url-pattern>*.shtml</url-pattern>
</servlet-mapping>
And create $CATALINA_HOME/conf/Catalina/localhost/<your app name>.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context privileged="true" >
</Context>

http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Introduction_to_SSL
You have to add the SSL configuration to the tomcat config this is detailed above and should help you out any questions after reading this let me know

Related

Can't access static resources (.html) files in Apache Tomcat 7.0.52

Even though I found some similar queries on the topic but can't find any answer suitable to my problem. My requirement is as follows -
I have installed my app (MyApp) in webapps dir of Apache Tomcat ver 7 web server. The dir structure is
/
|
|----api/
|
|----WEB-INF/
|
|----META-INF/
I have some static html files in the "api" dir(say index.html) which I want to access in the following way through a browser - http://localhost:8080/myapp/api/index.html
However, I can't access any static resources (html files) in this way. As far as I know any static outside WEB-INF can be accessed directly through the browser but I can't do it.
My web.xml looks something like this -
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>MyApp</display-name>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.core.Application</param-name>
<param-value>com.mycomp.MyApp</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/myapp/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
I'll appreciate any good help on this.
Thanks.
Try replacing the value for the tag url-pattern with some different name like /rest/* instead of myapp.
Now try accessing your url.

working of NTLMv2 with LDAP

I'm using NTLMv1 and its working fine. The only disdavantage is once if I logged in then its hitting LDAP server for 3 to 4 times.
So I don't want that. Can any one please explain me how this process is in NTLMv2?
below is the code for NTLMv2
<filter>
<filter-name>ntlmv2-auth</filter-name>
<filter-class>org.ntlmv2.filter.NtlmFilter</filter-class>
<init-param>
<!-- Windows domain name -->
<param-name>ntlm-domain</param-name>
<param-value>ACME.CORP</param-value>
</init-param>
<init-param>
<!-- IP-address of domain controller -->
<param-name>ntlm-dc</param-name>
<param-value>dcone.acme.com</param-value>
</init-param>
<init-param>
<!-- Simple (non-FQDN) hostname of DC host -->
<param-name>ntlm-dc-name</param-name>
<param-value>dcone</param-value>
</init-param>
<init-param>
<!-- Computer account for connection to DC -->
<param-name>ntlm-account</param-name>
<param-value>TECHUSER$#ACME.CORP</param-value>
</init-param>
<init-param>
<!-- Password of computer account -->
<param-name>ntlm-password</param-name>
<param-value>test1234</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>NTLMv2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
The answer is that you cannot avoid the repeated LDAP connection, as the NTLM protocol is designed to do this exactly. You can find more information on the Microsoft Page defining the NTLM Protocol

Why can't I read other files on Jetty, besides root.war?

I have root.war and cgi-bin-perl directory under Jetty's webapps directory. I am able to run the UI code in root.war, but I am not able to read cgi files and xml files under cgi-bin-perl directory, e.g. hello.cgi, plugin.xml. It returns the error "cannot be found". Here is my etc/webdefault.xml file. What do I miss?
<servlet>
<servlet-name>PerlCGI</servlet-name>
<servlet-class>org.eclipse.jetty.servlets.CGI</servlet-class>
<init-param>
<param-name>commandPrefix</param-name>
<param-value>/usr/bin/perl</param-value>
</init-param>
<init-param>
<param-name>cgibinResourceBase</param-name>
<param-value>/opt/jetty/webapps/cgi-bin-perl</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>PerlCGI</servlet-name>
<url-pattern>*.pl</url-pattern>
</servlet-mapping>
Your servlet mapping means that only patterns that end in pl will be executed by the servlet....there is nothing here that will serve out other files under that url.
If you want access to those files then you should setup a default servlet under that url space and let it serve out those files. By default jetty will not let you download whatever files you like, you have to configure it to do that!

JRuby Rack - How to add a servlet filter?

I'm trying (with no success) to pass the response of a JRuby Rack - Rails application to a filter in order to get it processed. Basically I want to use the Orbeon XForm Engine to enhance the XHTML output coming from my Rails application. If I use a simple Java servlet instead on JRuby Rack everything works smoothly.
Here's the web.xml file:
<!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>
<context-param>
<param-name>public.root</param-name>
<param-value>/</param-value>
</context-param>
<context-param>
<param-name>rails.env</param-name>
<param-value>production</param-value>
</context-param>
<context-param>
<param-name>jruby.min.runtimes</param-name>
<param-value>2</param-value>
</context-param>
<context-param>
<param-name>jruby.max.runtimes</param-name>
<param-value>4</param-value>
</context-param>
<filter>
<filter-name>orbeon-xforms-filter</filter-name>
<filter-class>org.orbeon.oxf.servlet.OrbeonXFormsFilter</filter-class>
<init-param>
<param-name>oxf.xforms.renderer.context</param-name>
<param-value>/orbeon</param-value>
</init-param>
</filter>
<!-- This is necessary so that XForms engine resources can be served appropriately -->
<filter-mapping>
<filter-name>orbeon-xforms-filter</filter-name>
<url-pattern>/orbeon/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!-- Any web resource under /xforms-jsp is processed by the XForms engine -->
<filter-mapping>
<filter-name>orbeon-xforms-filter</filter-name>
<url-pattern>/page/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter>
<filter-name>RackFilter</filter-name>
<filter-class>org.jruby.rack.RackFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RackFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
</listener>
</web-app>
Thanks in advance
Sandro.
I'm not familiar with Orbeon XForms, so I'm not positive about what your problem is. But according to the above web.xml, the Orbeon filters are only applied to /orbeon/* and /page/* URLs, while the Rack filter gets applied to everything.
If the servlet approach works, why not stick with that?

How to configure cache for static resources in web.xml for Jetty?

I was reading this:
http://docs.codehaus.org/display/JETTY/LastModifiedCacheControl
It says
The Jetty default servlet allows the cache control header to
be set for static content by using the cacheControl init parameter
using:
<init-param>
<param-name>cacheControl</param-name>
<param-value>max-age=3600,public</param-value>
</init-param>
However, I am not sure that I am using the default servlet. At least
such configuration is not in web.xml:
<web-app>
<display-name>Wicket QuickStart</display-name>
<context-param>
<param-name>configuration</param-name>
<param-value>development</param-value>
</context-param>
<servlet>
<servlet-name>quickstart</servlet-name>
<servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>wicket.quickstart.WicketApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>quickstart</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
I would like to configure cache for static resources such as:
/src/webapp/*, i.e.: /src/webapp/images, /src/webapp/css, /src/webapp/js, etc.
What should I add into my web.xml?
Need to add the following to your web.xml
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class>
<init-param>
<param-name>cacheControl</param-name>
<param-value>max-age=3600,public</param-value>
</init-param>
</servlet>