Menu

[r678]: / javaontracks / src / net / jot / web / JOTRewrittenRequest.java  Maximize  Restore  History

Download this file

66 lines (54 with data), 1.8 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
------------------------------------
JavaOnTracks Thibaut Colar
tcolar-jot AT colar DOT net
Artistic Licence 2.0
http://www.javaontracks.net
------------------------------------
*/
package net.jot.web;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.servlet.http.HttpServletRequest;
import net.jot.utils.JOTUtilities;
/**
* Extension of JOTFlowRequest allowing rewriting of the request URL "on the fly" without loosing the original request and associated parameters/attributes
* The original request is "wrapped" in a new request with the url, manipulated
* @author thibautc
*/
public class JOTRewrittenRequest extends JOTFlowRequest
{
private StringBuffer url;
private String uri=null;
private String path=null;
public JOTRewrittenRequest(HttpServletRequest request, String newPath, Hashtable attributes)
{
super(request);
url = new StringBuffer();
url.append(request.getScheme()).append("://").append(request.getServerName());
int port = request.getServerPort();
if(port!=80)
url.append(":" + port);
url.append(JOTUtilities.endWithForwardSlash(request.getContextPath())).append(newPath);
uri=JOTUtilities.endWithForwardSlash(request.getContextPath())+newPath;
path=newPath;
Enumeration e=attributes.keys();
while(e.hasMoreElements())
{
String key=(String)e.nextElement();
setParameter(key, (String)attributes.get(key));
}
}
public String getServletPath()
{
return path;
}
public String getRequestURI()
{
return uri;
}
public StringBuffer getRequestURL()
{
return url;
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.