Question

static def lemp(String aKey,String userName,String tType){
        def temp
         try {
           def ret = null
           def http = new HTTPBuilder("http://192.168.1.10:8080/Pay-0.1/main/msgPicTemp")
           http.parser.'text/html' = http.parser.'text/plain'
           http.request(Method.GET, ContentType.TEXT) {
               uri.query = [ appKey:appKey, userName:userName,tempType:tempType]
               headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4'
               response.success = { resp,reader -> println resp.status


            println reader.text
                temp=reader.text//i got error here,how to assign this to one variable and pass it to controller
                 }
               response.failure = { resp -> println "Unexpected error: ${resp.status} : ${resp.statusLine.reasonPhrase}" }
           }

          return temp
       } catch (groovyx.net.http.HttpResponseException ex) {
           ex.printStackTrace()
           return null
       } catch (java.net.ConnectException ex) {
           ex.printStackTrace()
           return null
       }
   }

Here reader gives the code like,

 <link rel="stylesheet" href="/Pay-0.1/static/css/bootstrap.css" type="text/css">
    <div align="left" style="background-color:#B8B8B8;width:150px">
    </div>
    Welcome

how to assign this reader to one variable and return to controller.and i want to display this one page from controller.

Was it helpful?

Solution

I believe the issue is with your println reader.text. Reading from the stream closes the stream. So your next line, to set the variable isn't going to work. Remove the println reader.text and see if you still have the issue

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top