• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to write javascript in servlet?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello friends,

I want to write javascript in servlet..

how could I write it.. ??
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RAHUL SURATI, you have already been asked once, please adjust your display name to be not all uppercase. Thanks.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The same way that write any of the other markup in a servlet: by emitting it as strings to the output stream.

It's not a good way to do things. Why are you not using JSPs to render the HTML/JavaScript markup?
 
Rahul Surati
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:The same way that write any of the other markup in a servlet: by emitting it as strings to the output stream.

It's not a good way to do things. Why are you not using JSPs to render the HTML/JavaScript markup?




I want to put presentaton logic and bussiness logic different .. so, I used servlet....

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rahul Surati wrote:I want to put presentaton logic and bussiness logic different .. so, I used servlet....


That makes no sense. How does not using a JSP for the HTML markup achieve this?

You may be interested in this article that explains modern web application structure.
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rahul

You may want to have a look at MVC architecture. To put it simply, put your 'business logic' in servlet (if you don't want to put in some other 'model' class) and send it to JSP, which will form the presentation layer.

I guess you wanted to avoid business logic in JSP and hence decided to put presentation logic in servlet, but as Bear said it is not correct too!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly. Putting Java in a JSP is a bad practice, but so is putting HTML into Java! Use each tool, servlets and JSP, to their best advantage!
 
reply
    Bookmark Topic Watch Topic
  • New Topic