File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes how to filter ajax response and display in jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to filter ajax response and display in jsp page" Watch "how to filter ajax response and display in jsp page" New topic
Author

how to filter ajax response and display in jsp page

rajeev panigrahi
Greenhorn

Joined: Oct 16, 2013
Posts: 2
I called jsp page from html page using jquery and ajax which is working properly but the response it displaing is a html code .see below.I have entered 1 and 3 and the sum of the two number shold display 4.but in the result it is displaying the complete html code with result.how to avoid it...........


first number: 1
second number: 3
result: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Insert title here</title></head><body>4</body></html>

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12674
    
    5
Why are you trying to use a .jsp page to perform a calculation? :confused:

JSP pages just naturally write all that HTML stuff you don't want to see. Instead, use a servlet for the computation, that way you totally control the returned text.

Bill

Java Resources at www.wbrogden.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

William Brogden wrote:JSP pages just naturally write all that HTML stuff you don't want to see.


Sorry, but that is not correct. A JSP will return only what is in its template. It does not naturally generate any HTML.

To the OP, if all you want to return is "4", that's all that should be in the response.

And yes, why a JSP?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
rajeev panigrahi
Greenhorn

Joined: Oct 16, 2013
Posts: 2
William Brogden wrote:Why are you trying to use a .jsp page to perform a calculation? :confused:

JSP pages just naturally write all that HTML stuff you don't want to see. Instead, use a servlet for the computation, that way you totally control the returned text.

Bill


I tried with servlet that also giving the same response..........do you have any other solution
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

What are you writing to the response in the servlet?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to filter ajax response and display in jsp page
 
Similar Threads
Servlet doubts
Tomcat: No Java compiler was found
JSP form Not working
How to display sum of numbers from a java class to a jsp using custom tag?
Simple factorial program