RE: Customize Url Rewriting + QUESTION

2001-07-31 Thread Ashish Bajpai


HI!
I looked at the apache rewrite stuff, however that is not
exactly what i was looking for. Let me explain it again
so that the requirement is more clear,
See when we are using the Url rewriting for session tracking
in Tomcat, each url in the page has got jsessionId appended
to it, my requirement is that can i extend this so that I can also
manipulate the url while the page is being served to the user.


thanks in anticipation

ashish


   

Loïc Lefèvre   

llefevre@fivTo: [EMAIL PROTECTED]  

ia.com  cc:   

 Subject: RE: Customize Url Rewriting + 
QUESTION   
07/30/2001 

12:33 PM   

Please 

respond to 

tomcat-user

   

   





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

Customize Url Rewriting

2001-07-30 Thread Ashish Bajpai

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




RE: Customize Url Rewriting

2001-07-30 Thread Loïc Lefèvre

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




RE: Customize Url Rewriting

2001-07-30 Thread Ashish Bajpai


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@fivTo: [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








RE: Customize Url Rewriting + QUESTION

2001-07-30 Thread Loïc Lefèvre

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@fivTo:
[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








RE: Customize Url Rewriting + QUESTION

2001-07-30 Thread Ashish Bajpai


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@fivTo: [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@fivTo:
[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












RE: Customize Url Rewriting + QUESTION

2001-07-30 Thread Loïc Lefèvre
 = 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