optimisation écriture listener
Bonjour,
Je cherche à optimiser le code ecrit dans ma jsp, je ne pas pu rendre satict ma méthode getTypDoc.
J'aimerai acceder à la méthode getTypDoc directement.
merci de vos suggestions
Dans ma jsp
Code:
1 2 3 4
|
ServletContext app = pageContext.getServletContext();
TypeDocUtils tdu = (TypeDocUtils) app.getAttribute("tdu");
defaultValue_typ_doc = tdu.getTypDoc(defaultValue_typ_doc); |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
public TypeDocUtils(){
myMap = new HashMap();
myMap.put ...
}
public String getTypDoc(String v){
Iterator iter = myMap_Doc.entrySet().iterator();
while(iter.hasNext()){
Map.Entry mEntry = (Map.Entry)iter.next();
if ( myMap .equals(mEntry.getKey())){
v = (String) mEntry.getValue();
}
}
return v;
} |
Code:
1 2 3 4
|
public void contextInitialized(ServletContextEvent event) {
event.getServletContext().setAttribute("tdu", new TypeDocUtils());
//TypeDocUtils tdu = new TypeDocUtils(); |