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!
Related
Mojibake problem
[I use netbeans - jsf 2.2 - primefaces 4.0 - Mysql database]
I use Arabic in my JSF application and unfortunately the Arabic values sent to the server as other characters like this (بÙÙس Ùب ) (seen by debugger) and so stored in database like this.
the project work well at the beginning but after I do some other tasks in my project this problem occur but what cause the problem I do not know
the following solutions done but no effect
use the following line at every jsf page (.xhtml page)
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
use the following filter
<filter>
<filter-name>encoding-filter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
and also I try my written filter
I use the form like this
<h:form acceptcharset="UTF-8" enctype="application/form-data">
Any one can help me
The problem here
Reconfigure the server to use UTF-8 instead of ISO-8859-1 as default encoding. In Glassfish, that would be a matter of adding the following entry to of the /WEB-INF/glassfish-web.xml file:
<parameter-encoding default-charset="UTF-8" />
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.
I am using a servlet which has this mapping (to a vaadin servlet actually)
<servlet-mapping>
<servlet-name>my Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
I want to make an exception for some html files that I have. It is ok if these are in a subfolder.
How do I do that? Is there a Tomcat-servlet to point to (in the part) which handles file reads?
Rob
Is there a Tomcat-servlet to point to (in the part) which handles file reads?
It's the DefaultServlet. As you can see in its documentation, its servlet name is default.
So, this should do, provided that those static files are in /static folder:
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/static/*</url-pattern>
</servlet-mapping>
Beware however, older Tomcat versions have a security bug whereby all contents of /WEB-INF and /META-INF are publicly accessible when (ab)using the default servlet this way.
See also:
How to access static resources when mapping a global front controller servlet on /*
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
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>