I use Windows server and apache tomcat. My application is deployed on root folder. So, if you want open my app you must send reqeust to checkerweb.tk/main.html.
What is the best way to redirect checkerweb.tk to checkerweb.tk/main.html?
Simple: In your WEB-INF/web.xml just add this fragment in the appropriate place
<welcome-file-list>
<welcome-file>main.html</welcome-file>
</welcome-file-list>
Related
I have made a web application to be deployed in the Websphere server but i came up with a problem.
I have 20 servlets that use a common parameter so i have this declared on web.xml:
<context-param>
<param-name>filePath</param-name>
<param-value>C:\logs.txt</param-value>
</context-param>
I want this parameter to be easily edited in the Websphere console but doesn't work. I know this works on Tomcat but is there anything equivalent on websphere?
Thanks
You should edit web.xml only on the server, there is know interface for it in the Console, as I remember.
You can find this file here:{WAS_ROOT}/profiles/profilename/config/cells/cellname/applications/enterpriseappname/deployments/deployedname/webmodulename
Link to the documentation:
http://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/tweb_jsfengine.html
I am using IBM WebSphere (WAS) 7.0.0.19 to host a java-based web-app, and I needed to map the extension *.html to a particular servlet so that I could do some server-side scrubbing of user-supplied HTML files. (The server reads the file, augments it with some extra information, and serves up the modified content transparently to the person viewing the page.)
Unfortunately, when I did this, welcome-files stopped working. Previously, if I typed in the URL for a directory, the server would look for index.html and serve up that. Now, I'm just getting a 403 forbidden rule ("Forbidden - by rule."). The access logs don't show anything more--they simply state that directory indexing is forbidden by rule for the server, which is correct. I don't want the webserver to build a table of contents for directories with no index.html, but when there is an index.html, I want it to serve up that file.
My first thought was that it was trying to serve the index.html through my servlet, the servlet was failing to find the file (because the url lacked "index.html"), and therefore it thought there was no index.html. However, I put in some debug code and am quite confident that the servlet code is never getting run when I go simply to the directory itself.
I don't really care whether index.html is served through the servlet or not--in the case of this particular file, the servlet would just spit back the original file anyway. I just want index.html to be served by something.
Here is the relevant section of my web.xml
<servlet-mapping>
<servlet-name>PageScrubber</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
For what it's worth, index.htm and index.jsp were not working before the addition of the servlet mapping. Only index.html worked before. However, now none of them work.
I have used the same web.xml with two Oracle products: WebLogic (WLS) and Oracle Application Server (OAS) with no issues.
I am quite confident that it is just the addition of this scrubber servlet that has caused the problem, because removing that directive caused directory indexing to start working again.
I did find some notes about welcome-file-list not working when using an extended document root, and I tried setting com.ibm.ws.webcontainer.EnablePartialURLtoExtendedDocumentRoot to be true, but that did not seem to change anything.
I'm pretty much out of ideas. Does anyone out there have any thoughts as to why it's not finding my index.html? Thanks in advance!
Caveat: I am working out of memory here.
The Welcome files used to be served by File Serving Servlet (or something that sounds similar to that).
This information would be in the WebSphere extensions file.
I would take a step back and remove your pageScrubber and get the file serving Servlet to serve the welcome files and see that things are working before getting back to using the PageScrubber.
These are my initial thoughts.
HTH
I have a Spring application, which is running on Tomcat say at: http://example.com/foo/
DisplatcherServlet is mapped to app/*, for example, index page is:
http://example.com/foo/app/index.html
This is so because I have other servlets (for HttpRequestHandlers), e.g. mapped to service/*. This scheme is convenient to use because this way app/ and service/ can have different security settings.
What I want is http://example.com/foo to redirect to http://example.com/foo/app/index.html.
How do I achieve this?
In your web.xml, you can define a welcome file, seen when navigating to the root of the app:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
You can then make a tiny index.jsp that redirects to where you want:
<% response.sendRedirect("app/index.html"); %>
You can add the (tuckey) Url Rewrite Filter to your application.
It provides you the functionality to define URL rewrite rules in you Application (ingoing and outgoing).
So you can define a rewrite rule for \ that it rewrites to myApplication.startpage - or something else.
#see: http://mattgivney.blogspot.com/2010/07/how-to-url-rewrite-in-spring-mvc.html - for a short example
i'm developping a web app (jsf 2.0 + facelets + richfaces 3.3.3 + oracle 10g + tomcat 6.0.26)
in my app, there's is 1 path that is not secured, and the others are secured (web.xml):
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/faces/login.jsp</form-login-page>
<form-error-page>/faces/error.jsp</form-error-page>
</form-login-config>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>Admin_Resource</web-resource-name>
<description/>
<url-pattern>/faces/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>A</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-role>
<description>Role admin</description>
<role-name>A</role-name>
</security-role>
So, this path is not secured: /faces/client/*.
when i move from https tp http, i use this function:
FacesContext.getCurrentInstance().getExternalContext().redirect("http://url/faces/client/page.xhtml");
When i deploy my app, and use this url: http(s)://url/MyContext/faces/..., all worked fine.
But when i moved my app to the ROOT context, so i use this url : http(s)://url/faces/, my https session is lost when i move from https to http, then back to https. My login page shows up, so i need to re-type my login and password.
Why is my session lost ? Is there something wrong ?
Add: when i deploy my app, here's what i do (external server):
put my war file into webapp folder
start my server (that will decompress my war into folders,...), then stop it
i delete my war file
i replace the content of ROOT folder with the content of the decompressed war file
and restart my server again
but all works fine when i put my war into webapp folder, then start the server (that's all).
So, i think it's a context problem.
Do you have any ideas ?
This an old question but it's worth answering because I just ran into it and the answer ended up being really simple. First, it makes complete sense that the session should be regenerated on the same session cookie name when going back and forth between HTTP and HTTPS. By default in Tomcat the session cookie name is JSESSIONID.
In Tomcat you can very simply change the name of the session cookie. I had two webapps, one HTTP and another HTTPS, for admin tools. Anytime the HTTP webapp opened I lost my session in the HTTPS webapp. All I had to do was add the sessionCookieName to the context of my HTTPS webapp:
<context sessionCookieName="ANOTHERCOOKIENAME" ...
This won't help if you're switching between HTTP and HTTPS in the same webapp, but you shouldn't do that anyway.
How can I integrate URL rewriting in my Glassfish v3 server?
The reason why I want to know this is that I am deploying a PHP application into my Glassfish server using Quercus.
But Quercus relies on mod_rewrite in the Apache Server to provide URL rewriting and this is not available in Glassfish.
Well, you have two options:
either front your GlassFish instance with Apache and use mod_rewrite
or use Tuckey's Url Rewrite Filter
I guess the former is not an option (or you wouldn't post this question). Regarding the later, you could adapt the solution given in Drupal on Glassfish with clean urls using Url Rewrite Filter. Basically, you'll have to:
Get Quercus's war and unpack it
Download the filter and unpack it inside Quercus (this will put the filter jar inside WEB-INF/lib and the urlrewrite.xml under WEB-INF)
Declare the filter in the web.xml (see the instruction)
"Port" your rewrite rules to the urlrewrite.xml file
repackage and deploy the war (or deploy it as an exploded archive)
I've been looking for the answer to this for a couple weeks.
Follow these instructions for JBoss:
http://tapomay.blogspot.com/2011/11/clean-urls-with-drupal-urlrewritefilter.html
He links to an article where one had done this for Tomcat: http://www.brianshowalter.com/blog/running_drupal_on_quercus
In a nutshell, you want to rewrite the URL only IF the requested file or directory do not exist on the system. This is why just UrlRewriteFilter is not enough. You have to add a class-filter to UrlRewriteFilter to check for this.
The instructions I linked to uses an older version of UrlRewriteFilter (3.2.0), it probably works just as well with the newer version (I did it with 3.2.0).
You will use that in conjunction with a class filter (there is a google project repository for this, thanks to the author of the linked article, at https://code.google.com/p/drupalrewritefilter/ )
The instructions say to add the files to Eclipse, but I used Netbeans (just start a new project with existing sources).
You'll need to add the servlet.api.jar (some where on your system, if you have J2EE installed) and the UrleRewriteFilter.jar file you are using to the classpath for the build.
Place the resulting drupalrewritefilter.jar file and the UrlRewriteFilter.jar file you are using in WEB-INF/lib
Your WEB-INF/web.xml should have this filter directive:
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>logLevel</param-name>
<param-value>TRACE</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Use this instead of the one the website for UrlRewriteFilter says to use.
NOTE: The Quercus install contains a DOCTYPE tag in the beginning for the Servlet API 2.2 or 2.3. But the <filter> tag is in the Servlet API 2.4 or higher. Your app will error-out unless you either link to a new Server API DTD or (and this is what I did) just delete the DOCTYPE tag all together.
Then you should have a WEB-INF/urlwrite.xml with:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
<class-rule class="com.brianshowalter.drupalrewrite.DrupalRule" />
</urlrewrite>
Reload your drupal app, and then go enable clean URLS's