Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

javascript when used inside servlet is not working  RSS feed

 
puja shaw
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
solved
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Secondly, why are you emitting HTML markup from a servlet? That's a poor practice -- you should be using a JSP for the markup.
 
puja shaw
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 120
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
puja shaw wrote:But my current requirement is using html in servlets.

Why? Is this a school assignment?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!