my dog learned polymorphism*
The moose likes Servlets and the fly likes javascript in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "javascript in servlet" Watch "javascript in servlet" New topic
Author

javascript in servlet

shanti ayyagari
Greenhorn

Joined: Sep 07, 2013
Posts: 1
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

Joined: Jan 10, 2002
Posts: 60780
    
  65

Have you looked at what the servlet is returning to the browser? Is it valid?

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sam Jimzz
Greenhorn

Joined: Apr 30, 2011
Posts: 28

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..


God Loves You and will never love you less.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

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

Joined: Apr 30, 2011
Posts: 28

But i used something like this

before 3 years to make a script code work under Oracle container..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

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

Joined: Apr 30, 2011
Posts: 28

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...
 
wood burning stoves
 
subject: javascript in servlet
 
Similar Threads
Radio button
can i use javascript inside the servlet
external javascript file
Opening a page with details about an item (servlet)
embedding javascript into servlet