This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes javascript when used inside servlet is not working Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "javascript when used inside servlet is not working" Watch "javascript when used inside servlet is not working" New topic
Author

javascript when used inside servlet is not working

puja shaw
Ranch Hand

Joined: Nov 06, 2012
Posts: 32
solved
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56180
    
  13

Secondly, why are you emitting HTML markup from a servlet? That's a poor practice -- you should be using a JSP for the markup.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
puja shaw
Ranch Hand

Joined: Nov 06, 2012
Posts: 32
Bear Bibeault wrote:Secondly, why are you emitting HTML markup from a servlet? That's a poor practice -- you should be using a JSP for the markup.


i know that we can use jsp's.But my current requirement is using html in servlets.
kumar naresh
Ranch Hand

Joined: Mar 12, 2011
Posts: 108
    
    1
Try by placing complete thing in out.println("<script language=\"javascript\"/>). Also try by getting an instance of JSPWriter in the class and use it for writing the script code.


OCMJEA 5 |
http://sceacertification.blogspot.in/2011_12_01_archive.html
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56180
    
  13

puja shaw wrote:But my current requirement is using html in servlets.

Why? Is this a school assignment?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56180
    
  13

kumar naresh wrote:Also try by getting an instance of JSPWriter in the class and use it for writing the script code.

Not possible from a servlet.
puja shaw
Ranch Hand

Joined: Nov 06, 2012
Posts: 32
Bear Bibeault wrote:
puja shaw wrote:But my current requirement is using html in servlets.

Why? Is this a school assignment?


unfortunately yes.So please help me to make it work.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56180
    
  13

<mild-rant>Why schools insist on teaching stupid things like this is beyond me. When I was teaching, I always made sure that good industry practices were emphasized.</mild-rant>

Step 1: Look at what's delivered to the browser by doing a View Source. Is it correct? Is it well-formed? Are there syntax errors?
Step 2: If so, use the browser's JavaScript debugger to see if the script is running or throwing errors.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56180
    
  13

In the future please let us know when a question is a school assignment that has strict requirements. Otherwise, time is wasted trying to find out why you are trying to do things the wrong way.
puja shaw
Ranch Hand

Joined: Nov 06, 2012
Posts: 32
Bear Bibeault wrote:In the future please let us know when a question is a school assignment that has strict requirements. Otherwise, time is wasted trying to find out why you are trying to do things the wrong way.


oops..ok.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: javascript when used inside servlet is not working
 
Similar Threads
document.getElementById() not working
Two actions in a single JSP
How to get ajax response in jsp page
drop down list changed
option values are not being shown when using javascript