java - JSP Application Scope settings for Database Query -


i want store query result in hashmap each "service" parameter passed class , store them application scope application.setattribute() , if service exist in application scope values application.getattribute(). there 3 columns stored each service. how can 3 column values depending upon services parameter if exist in application scope? please suggest how store values in application scope (if doing wrong in following code).

 service=request.getparameter("service");     map<string,string> freetextmap=new hashmap<string,string>();  if(application.getattribute(service)==null ) { query = "select aunique,atitle,abody freetexts service='" +service+ "'      rs = dbutils.getrs(con,query); if (rs.next()) { clientfreetextmap.put("unique", rs.getstring("aunique")); clientfreetextmap.put("body",rs.getstring("abody")); clientfreetextmap.put("txt",rs.getstring("atitle")); application.setattribute(service,clientfreetextmap);   } 

the following code responsible getting values application scope it's not able know missing declare services. not having idea write service?? how values respect service parameter??

    else       {    txt=(string) application.getattribute(clientfreetextmap.get("txt"));    uniqueid=(string) application.getattribute(clientfreetextmap.get("unique"));    adsbody=(string) application.getattribute(clientfreetextmap.get("body"));      } 

you storing clientfreetextmap in if block. should same map out in else block, data need that. try this:

clientfreetextmap = (map)application.getattribute(service); txt = clientfreetextmap.get("txt"); uniqueid = clientfreetextmap.get("unique"); adsbody = clientfreetextmap.get("body"); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -