1 package org.ashkelon.pages; 2 3 import org.ashkelon.util.*; 4 import java.util.*; 5 import javax.servlet.http.*; 6 7 10 public class Trail extends Page 11 { 12 public Trail() 13 { 14 super(); 15 log.setPrefix("trail"); 16 } 17 18 public String handleRequest() 19 { 20 String cmd = ServletUtils.getCommand(request); 21 if (cmd.equals("trail.reset")) 22 { 23 return resetTrail(request); 24 } 25 return null; 26 } 27 28 private String resetTrail(HttpServletRequest request) 29 { 30 HttpSession session = request.getSession(true); 31 LinkedList trail = (LinkedList) session.getAttribute("trail"); 32 if (trail == null || trail.isEmpty()) 33 return "pkg"; 34 35 String [] lastPair = (String []) trail.getLast(); 36 String last_uri = lastPair[0]; 37 38 String cmd = "pkg"; 39 if (last_uri.indexOf("?") > 0) 40 { 41 String queryString = StringUtils.split(last_uri, "?")[1]; 42 String [] pairs = StringUtils.split(queryString, "&"); 43 String [] name_value; 44 for (int i=0; i<pairs.length; i++) 45 { 46 name_value = StringUtils.split(pairs[i], "="); 47 request.setAttribute(name_value[0], name_value[1]); 48 if ("cmd".equals(name_value[0])) 49 cmd = name_value[1]; 50 } 51 } 52 session.setAttribute("trail", new LinkedList()); 53 log.traceln("trail has been reset"); 54 return cmd; 55 } 56 57 } 58 | Popular Tags |