• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

javascript in servlet

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.?

 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at what the servlet is returning to the browser? Is it valid?
 
Greenhorn
Posts: 28
Mac Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic