1 37 package net.thauvin.google.taglibs; 38 39 import net.thauvin.google.GoogleSearchBean; 40 import net.thauvin.google.TagUtility; 41 42 import javax.servlet.jsp.JspException ; 43 44 45 53 public class Spelling extends QuerySupport 54 { 55 61 public int doEndTag() 62 throws JspException 63 { 64 final String query = getQuery(); 65 66 if (TagUtility.isValidString(query, true)) 67 { 68 try 69 { 70 final GoogleSearchBean bean = new GoogleSearchBean(getKey()); 71 72 bean.setProxyServer(pageContext.getServletContext() 73 .getInitParameter(TagUtility.GOOGLE_PROXY_HOST), 74 pageContext.getServletContext() 75 .getInitParameter(TagUtility.GOOGLE_PROXY_PORT), 76 pageContext.getServletContext() 77 .getInitParameter(TagUtility.GOOGLE_PROXY_USERNAME), 78 pageContext.getServletContext() 79 .getInitParameter(TagUtility.GOOGLE_PROXY_PASSWORD)); 80 81 String result = bean.getSpellingSuggestion(query); 82 83 if (!TagUtility.isValidString(result, true)) 84 { 85 result = query; 86 } 87 88 pageContext.getOut().write(result); 90 } 91 catch (Exception e) 92 { 93 throw TagUtility.outputError("Spelling", e); 94 } 95 } 96 97 reset(); 99 100 return EVAL_PAGE; 101 } 102 103 106 public void release() 107 { 108 super.release(); 109 110 reset(); 112 } 113 114 117 protected void reset() 118 { 119 super.reset(); 120 } 121 } 122 | Popular Tags |