Okay, let's speak ;)
here is my mod_jk.conf:
##############################################
# TOMCAT mod_jk.so MODULE CONFIGURATION FILE #
##############################################
JkWorkersFile /usr/local/tomcat/jakarta-tomcat-3.2.3/conf/workers.properties
JkLogFile /usr/local/tomcat/log/mod_jk.log
#
# Log level to be used by mod_jk
# debug / error / warn / info / fatal
#
JkLogLevel debug
NameVirtualHost 192.1.1.128
<VirtualHost 192.1.1.128>
ServerName lol.fivia.com
# Répertoire ou commence le site, pour les fichiers statiques
DocumentRoot /usr/local/tomcat/jakarta-tomcat-3.2.3/webapps/lol
JkMount /lol/* ajp12
JkMount /*.jsp ajp12
RedirectMatch /index.html $1/start/index.html
ErrorLog /usr/local/tomcat/log/lol_error_html.log
TransferLog /usr/local/tomcat/log/lol_access_html.log
RewriteEngine on
RewriteLog /usr/local/tomcat/log/lol_rewrite.log
RewriteLogLevel 9
# Seen in a faq (: http://www.jguru.com/faq/view.jsp?EID=53878)
RewriteRule ^(/.*;jsessionid=.*)$ $1 [T=jserv-servlet,PT]
RewriteCond %{REQUEST_URI} ^/servlet* [NC]
RewriteRule ^/servlet/(.*) /lol/$1 [PT]
RewriteCond %{REQUEST_URI} !^/lol* [NC]
RewriteCond %{REQUEST_URI} !^/Image* [NC]
RewriteCond %{REQUEST_URI} !^/Elemtech* [NC]
RewriteCond %{REQUEST_URI} !^/Erreur* [NC]
RewriteCond %{REQUEST_URI} ^/.*/.*
RewriteRule ^/(.*) /lol/AdFront?access=/$1 [PT,QSA]
#RewriteRule ^/Image/(.*) /Image/$1 [L,NC]
#RewriteRule ^/Erreur/(.*) /Erreur/$1 [L,NC]
#RewriteRule ^/Elemtech/(.*) /Elemtech/$1 [L,NC]
#RewriteRule ^/servlet/(.*) /lol/$1 [PT]
#RewriteCond %{REQUEST_URI} ^/.*/.*
#RewriteRule ^/(.*) /lol/AdFront?access=/$1 [QSA]
</VirtualHost>
here is the code of my URLRewriter:
package com.fivia.adfront.sales;
import com.fivia.adfront.sales.kernel.*;
import com.fivia.adfront.sales.util.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.StringTokenizer;
import java.util.Date;
public class AdURLRewriter extends HttpServlet
{
public static AdFront application = null;
public static int p = 0;
/****************************************************************/
/* Initialisation
*/
/****************************************************************/
public void init(ServletConfig config)
throws ServletException
{
System.out.println("Initialisation d'AdURLRewriter en cours...");
super.init(config);
// Instanciation de l'application (static !)
if( application == null )
{
application = new AdFront();
application.init(config);
}
}
/****************************************************************/
/* Destroy
*/
/****************************************************************/
public void destroy()
{
System.out.println("Destruction d'AdURLRewriter...");
super.destroy();
}
/****************************************************************/
/* GET method */
/****************************************************************/
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException
{
p++; // to debug
if( p <= 3) // I just redirect the 3rd first uri
{
if( request.getRequestURI().startsWith("/lol/AdFront") ||
request.getRequestURI().startsWith("/servlet/AdFront") )
application.doGet(request,response);
else
response.sendRedirect("/lol/AdFront?access="+request.getRequestURI());
}
else
{
// Snnop servlet (Tomcat) code
PrintWriter out = response.getWriter();
response.setContentType("text/plain");
out.println("Snoop Servlet");
out.println();
out.println("Servlet init parameters:");
Enumeration e = getInitParameterNames();
while (e.hasMoreElements())
{
String key = (String)e.nextElement();
String value = getInitParameter(key);
out.println(" " + key + " = " + value);
}
out.println();
out.println("Context init parameters:");
ServletContext context = getServletContext();
Enumeration enum = context.getInitParameterNames();
while (enum.hasMoreElements()) {
String key = (String)enum.nextElement();
Object value = context.getInitParameter(key);
out.println(" " + key + " = " + value);
}
out.println();
out.println("Context attributes:");
enum = context.getAttributeNames();
while (enum.hasMoreElements()) {
String key = (String)enum.nextElement();
Object value = context.getAttribute(key);
out.println(" " + key + " = " + value);
}
out.println();
out.println("Request attributes:");
e = request.getAttributeNames();
while (e.hasMoreElements()) {
String key = (String)e.nextElement();
Object value = request.getAttribute(key);
out.println(" " + key + " = " + value);
}
out.println();
out.println("Servlet Name: " + getServletName());
out.println("Protocol: " + request.getProtocol());
out.println("Scheme: " + request.getScheme());
out.println("Server Name: " + request.getServerName());
out.println("Server Port: " + request.getServerPort());
out.println("Server Info: " + context.getServerInfo());
out.println("Remote Addr: " + request.getRemoteAddr());
out.println("Remote Host: " + request.getRemoteHost());
out.println("Character Encoding: " +
request.getCharacterEncoding());
out.println("Content Length: " + request.getContentLength());
out.println("Content Type: "+ request.getContentType());
out.println("Locale: "+ request.getLocale());
out.println("Default Response Buffer: "+ response.getBufferSize());
out.println();
out.println("Parameter names in this request:");
e = request.getParameterNames();
while (e.hasMoreElements()) {
String key = (String)e.nextElement();
String[] values = request.getParameterValues(key);
out.print(" " + key + " = ");
for(int i = 0; i < values.length; i++) {
out.print(values[i] + " ");
}
out.println();
}
out.println();
out.println("Headers in this request:");
e = request.getHeaderNames();
while (e.hasMoreElements()) {
String key = (String)e.nextElement();
String value = request.getHeader(key);
out.println(" " + key + ": " + value);
}
out.println();
out.println("Cookies in this request:");
Cookie[] cookies = request.getCookies();
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
out.println(" " + cookie.getName() + " = " +
cookie.getValue());
}
out.println();
out.println("Request Is Secure: " + request.isSecure());
out.println("Auth Type: " + request.getAuthType());
out.println("HTTP Method: " + request.getMethod());
out.println("Remote User: " + request.getRemoteUser());
out.println("Request URI: " + request.getRequestURI());
out.println("Context Path: " + request.getContextPath());
out.println("Servlet Path: " + request.getServletPath());
out.println("Path Info: " + request.getPathInfo());
out.println("Path Trans: " + request.getPathTranslated());
out.println("Query String: " + request.getQueryString());
out.println();
HttpSession session = request.getSession();
out.println("Requested Session Id: " +
request.getRequestedSessionId());
out.println("Current Session Id: " + session.getId());
out.println("Session Created Time: " + session.getCreationTime());
out.println("Session Last Accessed Time: " +
session.getLastAccessedTime());
out.println("Session Max Inactive Interval Seconds: " +
session.getMaxInactiveInterval());
out.println();
out.println("Session values: ");
Enumeration names = session.getAttributeNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
out.println(" " + name + " = " + session.getAttribute(name));
}
}
}
/****************************************************************/
/* POST method. */
/****************************************************************/
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
doGet(req, res);
}
}
Now, I have to manage the login POST form...
If you have any quesion / idea ?
Loïc Lefèvre
-----Message d'origine-----
De : Ashish Bajpai [mailto:[EMAIL PROTECTED]]
Envoyé : lundi 30 juillet 2001 18:20
À : [EMAIL PROTECTED]
Objet : RE: Customize Url Rewriting + QUESTION
HI! Loïc
I am also using the 3.2.3 version, I think i should have a
look at the 4.0 version also.
I think the approach that you are taking to handle the rewriting
is a good one, though i have got a question on that
how do you get to know that you have encountered a url, let me
rephrase it.
Like you have a hunk of a content in which there are a lot
of <a> tags and form acitons now how will your rewriter get
triggered so that it rewrites the urls before it gets out
to the user.
I mean to ask how does your rewriter plugs into the whole scheme of
things
TAI
ashish
Loïc Lefèvre
<llefevre@fiv To:
<[EMAIL PROTECTED]>
ia.com> cc:
Subject: RE: Customize Url
Rewriting + QUESTION
07/30/2001
12:13 PM
Please
respond to
tomcat-user
Yes you can, I'm developping a URLRewriter servlet because of the
problemSSS
I
encounter using mod_rewrite alone :(
I Load it on startup and manage myself the url rewriting by using
response.sendRedirect or
myMainApplicatioSerlvet.doGet(request,response) + some simple rules ;)
Using servlet aliasing in tomcat is not as powerful as I expect.
Does tomcat 3.3 or 4.0 use more regular expressions for this?
(I use tomcat 3.2.3).
Loïc Lefèvre
-----Message d'origine-----
De : Ashish Bajpai [mailto:[EMAIL PROTECTED]]
Envoyé : lundi 30 juillet 2001 17:55
À : [EMAIL PROTECTED]
Objet : RE: Customize Url Rewriting
Thanks
I will try it. In the mean while is it essential for me to use
apache ? can i do something by only using Tomcat.
thanks
ashish
Loïc Lefèvre
<llefevre@fiv To:
<[EMAIL PROTECTED]>
ia.com> cc:
Subject: RE: Customize Url
Rewriting
07/30/2001
11:51 AM
Please
respond to
tomcat-user
The answer is YES, using mod_rewrite apache module.
Add it to your <VirtualHost></VirtualHost> or in mod_jk.conf
if you don't use Virtual Host.
example:
RewriteEngine on
RewriteLog /usr/local/tomcat/logs/rewrite.log
RewriteLogLevel 9
RewriteCond %{REQUEST_URI} ^/(.*) [NC]
RewriteRule ^/(.*) /index.jsp?$1 [PT]
;-)
-----Message d'origine-----
De : Ashish Bajpai [mailto:[EMAIL PROTECTED]]
Envoyé : lundi 30 juillet 2001 17:38
À : [EMAIL PROTECTED]
Objet : Customize Url Rewriting
Hi!
I was wondering if there is a way that one can add something to
the url rewirting scheme.
To make things clear what i want is this
Can i plugin some code so that all the urls in the html/jsp pages for
my site can have a content attirbute some thing of this sort.
http://mysite.com/home/ugotit.jsp becomes
http://mysite.com/index.jsp?jsessionid=......&content=ugotit.jsp.
TAI
ashish