cancel
Showing results for 
Search instead for 
Did you mean: 

How to write http status code in red or green in a file?

Frequent Contributor

How to write http status code in red or green in a file?

Hi,

I'm trying to generate a pdf file for my report.

I need to display status code in green if it's 200 otherwise in red.

i tried this:

i get status from a project property 

if(status == '200'){
Chunk statuscode = new Chunk ("Status is: "+status, smallBold)
status.setBackground(BaseColor.GREEN)
Paragraph p =  new Paragraph(status)
}else if (status != '200'){
Chunk statuscode = new Chunk ("Status is: "+status, smallBold)
status.setBackground(BaseColor.RED)
Paragraph p =  new Paragraph(status)
}else{
log.info "ERROR"
}

document.add(p)

It creates file with 0k.Cannot open it

 

1 REPLY 1
Highlighted
Frequent Contributor

Re: How to write http status code in red or green in a file?

Problem resolved.

The last line as outside the test.

I added this 

document.add(p)

Now it works:

It gets the httpcode of my request then writes in pdf file with color chunk red or green depending the status. 

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors