java servlets

do we need to put orr java coding in html page into a servlet

Page 1 of 1

3 Replies - 639 Views - Last Post: 24 December 2009 - 09:22 PM Rate Topic: -----

#1 snu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-December 09

java servlets

Posted 24 December 2009 - 03:00 PM

do we have to put our java coding alond with the html pages into a servlet so that a servlet generates a response i.e. sends a web age to the client when he requests for it.
servlet is a program running at the server which provides a response for the user requests. am i right??
Is This A Good Question/Topic? 0
  • +

Replies To: java servlets

#2 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 561
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: java servlets

Posted 24 December 2009 - 03:34 PM

When creating servlets, its best not to mix java code with html. Best practice is to create somthing called beans, but this is going into quite a large area. I am not to sure by what you mean in your other part. From what I can make out, your kinda correct. Many tutorials out there which will help you understand better.
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: java servlets

Posted 24 December 2009 - 07:46 PM

you might have a more complete response in the JavaEE forum
Was This Post Helpful? 0
  • +
  • -

#4 AbuJaFaR  Icon User is offline

  • D.I.C Regular

Reputation: 13
  • View blog
  • Posts: 330
  • Joined: 13-December 07

Re: java servlets

Posted 24 December 2009 - 09:22 PM

First of all, jsp has nothing to do with servlets in the beginning.
A jsp can contain either only java code or java code embedded between html tags.
The first time those jsp's invoked are compiled to Java servlets.

To be more specific, the jsp page is translated into a java class and after into a Servlet.(This happens only the first time- thats because you may notice a little delay the first time)

Now the Servlet , in the end, is a java class containing methods from the Java Servlet API. ( javax.servlet.* )
Among the other methods that implements, also has the _jspService method where there your code is embedded.(html + jsp)
That's a summary for what is going on.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1