0

How to remove html code from response

asked 2016-04-26 15:06:30 +0800

hswain gravatar image hswain flag of India
1763 3 10
http://corejavaexample.bl...

I am using below code for json response. But its return with html code. Please let me know how i will remove this html code form response.

my client side call here

$.get("/json.zul", function(data, status){
                alert("Data: " + data + "\nStatus: " + status);
            });

java code.

HttpServletResponse response = (HttpServletResponse) Executions.getCurrent().getNativeResponse();

        String objectToReturn = "{ key1: 'value1', key2: 'value2' }";
        response.setContentType("application/json");
        PrintWriter out;
        try {
            out = response.getWriter();
            out.print(objectToReturn);
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }

output response.

{ key1: 'value1', key2: 'value2' }

<!DOCTYPE html>
<html>
<head>
<title></title>

<link rel="stylesheet" type="text/css" href="/MedXEMR/zkau/web/ccf53197/zul/css/zk.wcs"/>
<!-- ZK 7.0.7 EE 2015121516 -->
<script class="z-runonce" type="text/javascript">
zkopt({ppos:'center'});
</script></head>
<body>
<div id="wCDP_" class="z-temp"><div id="zk_proc" class="z-loading"><div class="z-loading-indicator"><span class="z-loading-icon"></span>Processing...</div></div></div>
<script class="z-runonce" type="text/javascript">
zkmx(
[0,'wCDP_',{dt:'z_72f',cu:'\x2FMedXEMR',uu:'\x2FMedXEMR\x2Fzkau',ru:'\x2Fjson.zul'},[
['zul.wnd.Window','wCDP0',{$$onMinimize:false,$$0onMinimize:true,$$onZIndex:false,$$0onZIndex:true,$$onMove:false,$$0onMove:true,$onClose:true,$$onOpen:false,$$onMaximize:false,$$0onMaximize:true,$$onSize:false,$$0onSize:true,prolog:'\n\t'},[]]]]);

</script>
<noscript>
<div class="noscript"><p>Sorry, JavaScript must be enabled.<br/>Change your browser options, then <a href="">try again</a>.</p></div>
</noscript>

</body>
</html>

requirement is only json not with html code.

{ key1: 'value1', key2: 'value2' }

delete flag offensive retag edit

Comments

Hello hswain,

Have you tried: response.getEntity() ?

Best Regards,

Darksu

Darksu ( 2016-04-27 06:35:46 +0800 )edit

after added josn in response its not coming with success response. if i removed the json from response it coming. Inside browser network its showing.

hswain ( 2016-04-27 08:42:59 +0800 )edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-04-26 15:06:30 +0800

Seen: 24 times

Last updated: Apr 27 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More