aspose file tools*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
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: 61417
    
  67

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 120
    
    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: 61417
    
  67

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: 61417
    
  67

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: 61417
    
  67

<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: 61417
    
  67

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://aspose.com/file-tools
 
subject: javascript when used inside servlet is not working