1 /*
2 * Copyright 2000-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.apache.jetspeed.modules.actions;
18
19 // Java Core Classes
20 import java.util.Enumeration;
21
22 // Jetspeed Modules
23 import org.apache.jetspeed.util.URILookup;
24
25 // Turbine Modules
26 import org.apache.turbine.modules.Action;
27 import org.apache.turbine.util.RunData;
28
29 /***
30 * Marks the referer page to enable buttons as "back"
31 *
32 * @author <A HREF="shesmer@raleigh.ibm.com">Stephan Hesmer</A>
33 */
34 public class MarkRefPage extends Action
35 {
36 public void doPerform( RunData data ) throws Exception
37 {
38 Enumeration enum = data.getRequest().getHeaderNames();
39 while (enum.hasMoreElements()) {
40 String name = (String)enum.nextElement();
41 if ("referer".equalsIgnoreCase(name)) {
42 // check name case insensitive, because getHeader checks case-sensitive,
43 // though it is defined as case-insensitive in the servlet specification
44 String uri = data.getRequest().getHeader(name);
45 if (uri!=null) {
46 // remove sessionid, if exists
47 if (uri.indexOf(";jsessionid")!=-1) {
48 uri = uri.substring(0,uri.indexOf(";jsessionid"));
49 }
50 // adds sessionid if necessary
51 uri = data.getResponse().encodeURL( uri );
52 URILookup.markPage( uri, data);
53 }
54 break;
55 }
56 }
57 }
58
59 }