KEMBAR78
Java Servlets Part 2 | PDF
http://gsbprogramming.blogspot.in
 Open Eclipse IDE and Click FileNew ProjectDynamic Web Project
 Or Press Ctrl+N. New project wizard will open
http://gsbprogramming.blogspot.in
 In Web Section select Dynamic Web Project:
 Give a name to your project and keep other things as default and click Next.
 Check the Generate Web.xml deployment descriptor
 Click the Finish Button
 Open the Project Explorer using WindowShow ViewProject Explorer
http://gsbprogramming.blogspot.in
 Navigator Window shows actual directory structure:
http://gsbprogramming.blogspot.in
 To get the location of your project name, right click project then go to properties:
 Open the web.xml file either from navigator or project explorer window.
WebContent will be the directory for storing the web contents. You can change these both
options while creating your new project. For example:
http://gsbprogramming.blogspot.in
http://gsbprogramming.blogspot.in
<welcome-file-list> is list of welcome pages. Whenever user accesses the website, any one
of the page (which is available)from this list is rendered. For example, if we have index.html
in our previous project:
http://gsbprogramming.blogspot.in
Now, when user tries to access the website using http://localhost:8081/ServletDemo1/ then
index.html will be rendered:
Consider the following web.xml:
Now, we have index1.html, index2.html and index3.html in web.xml and also in project. So
index1.html will be rendered when user accesses http://localhost:8081/ServletDemo1/
because it is the first file in welcome list. If index1.html is not present then next file
http://gsbprogramming.blogspot.in
index2.html will be searched and rendered. In case none of the file is present then 404 error
will be shown:
Running the Project
 Start the server by opening the Servers window, then right click server and start
http://gsbprogramming.blogspot.in
 Run the project by right clicking the project and selecting Run As Run on Server:
 Select the server name and make sure its State is Started and click Next
http://gsbprogramming.blogspot.in
 Move your project to right panel and click Finish
 Your website will be rendered with first welcome file if exists.
 Now you can use any browser present in your system with following url:
http://localhost:8081/<Context-Root> which is in our case:
http://localhost:8081/ServletDemo1/

Java Servlets Part 2

  • 1.
    http://gsbprogramming.blogspot.in  Open EclipseIDE and Click FileNew ProjectDynamic Web Project  Or Press Ctrl+N. New project wizard will open
  • 2.
    http://gsbprogramming.blogspot.in  In WebSection select Dynamic Web Project:  Give a name to your project and keep other things as default and click Next.  Check the Generate Web.xml deployment descriptor  Click the Finish Button  Open the Project Explorer using WindowShow ViewProject Explorer
  • 3.
  • 4.
    http://gsbprogramming.blogspot.in  To getthe location of your project name, right click project then go to properties:  Open the web.xml file either from navigator or project explorer window. WebContent will be the directory for storing the web contents. You can change these both options while creating your new project. For example:
  • 5.
  • 6.
    http://gsbprogramming.blogspot.in <welcome-file-list> is listof welcome pages. Whenever user accesses the website, any one of the page (which is available)from this list is rendered. For example, if we have index.html in our previous project:
  • 7.
    http://gsbprogramming.blogspot.in Now, when usertries to access the website using http://localhost:8081/ServletDemo1/ then index.html will be rendered: Consider the following web.xml: Now, we have index1.html, index2.html and index3.html in web.xml and also in project. So index1.html will be rendered when user accesses http://localhost:8081/ServletDemo1/ because it is the first file in welcome list. If index1.html is not present then next file
  • 8.
    http://gsbprogramming.blogspot.in index2.html will besearched and rendered. In case none of the file is present then 404 error will be shown: Running the Project  Start the server by opening the Servers window, then right click server and start
  • 9.
    http://gsbprogramming.blogspot.in  Run theproject by right clicking the project and selecting Run As Run on Server:  Select the server name and make sure its State is Started and click Next
  • 10.
    http://gsbprogramming.blogspot.in  Move yourproject to right panel and click Finish  Your website will be rendered with first welcome file if exists.  Now you can use any browser present in your system with following url: http://localhost:8081/<Context-Root> which is in our case: http://localhost:8081/ServletDemo1/