Home arrow static arrow Java Programming [Archive] - how to insert javascript with in a servlet
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - how to insert javascript with in a servlet
This topic has 5 replies on 1 page.

Posts:1
Registered: 5/4/04
how to insert javascript with in a servlet  
May 4, 2004 6:54 PM



 
Please send the code to insert javascript with in a servlet
 

Posts:7,258
Registered: 1/31/02
Re: how to insert javascript with in a servlet  
May 4, 2004 7:01 PM (reply 1 of 5)



 
You can write anything you want back to the browser from a servlet, so you can certainly write JavaScript out if you want (ick). Look at the getWriter method on ServletResponse for how to write stuff back (don't forget to set your content type and to call flush() on the Writer)

Good Luck

Lee
 

Posts:1
Registered: 10/10/03
Re: how to insert javascript with in a servlet  
May 4, 2004 8:33 PM (reply 2 of 5)



 
hi,
You have write u r java script code in Servlet with teh following steps

1.Use out.println("<html> .....</html>")

in between the above html code u write ur <script language="javascript"> etc

write your javascript code in the above <sript tah function.

Hope this helps

-Srini
 

Posts:2,578
Registered: 01/11/02
Re: how to insert javascript with in a servlet  
May 5, 2004 12:55 AM (reply 3 of 5)



 
Please send the code to insert javascript with in a
servlet

Shhh, ze code is "Nightingale". Now burn zis post!
 

Posts:192
Registered: 7/7/04
Re: how to insert javascript with in a servlet  
Jul 7, 2004 4:10 AM (reply 4 of 5)



 
Seriously speaking, the code is this...

out.println("<script language=\"javascript\">");
out.println("function func(){");
out.println("document.write('your code');");
out.println("</script>");

where out is a PrintWriter object.

Hope this helps...Cheers !!!
 

Posts:317
Registered: 8/30/02
Re: how to insert javascript with in a servlet  
Jul 7, 2004 4:49 AM (reply 5 of 5)



 
just by the way: there is an extra forum for servlet questions.
 
This topic has 5 replies on 1 page.