This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

javascript in servlet  RSS feed

 
shanti ayyagari
Greenhorn
Posts: 1
  • 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
Posts: 66144
143
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
  • 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
Posts: 66144
143
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
  • 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
Posts: 66144
143
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
  • 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...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!