File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javascript in servlet

 
shanti ayyagari
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi All,

I'm calling a Call_List servlet from a abc.js file as below:

document.frm2.action = "../servlet/min.max.custom.Call_ListCheck';
document.frm2.target='formSaveFrame';
document.frm2.submit();

In Call_List. servlet, I want to make an alert as below:

out.println("

<script language=javascript>"); out.println("alert('SUCCESS')"); out.println("</script>
");

but, this script given in the servlet is not getting called. Only, if abc.js throws some error, this script is being called.

This means, is abc.js holding control? how do i make the alert come up from the servlet.?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at what the servlet is returning to the browser? Is it valid?
 
Sam Jimzz
Greenhorn
Posts: 28
Eclipse IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Symbols like ("< and >") behaves differently while generating js from servlets. Check your script code in JSP which is generated by Servlet.
Try using escape sequence on those symbols..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sam Jimzz wrote:Symbols like ("< and >") behaves differently while generating js from servlets.
No, there is nothing special about those characters when emitting response output from a servlet.
 
Sam Jimzz
Greenhorn
Posts: 28
Eclipse IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But i used something like this

before 3 years to make a script code work under Oracle container..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That has nothing to do with the angle bracket characters, or even JavaScript. The escaping simply is to allow double quotes in Java strings.
 
Sam Jimzz
Greenhorn
Posts: 28
Eclipse IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:That has nothing to do with the angle bracket characters, or even JavaScript. The escaping simply is to allow double quotes in Java strings.


Yes...agreed...
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic