Friday, June 15, 2012

"Hello World " servlet in Net Beans

By default there is no web application in Net Beans 7.1 so you have to install plugin of web application.In order to do that, go to tool>plugin.A window will pop-up where all updates,available plugins,downloaded, installed  plugins option are available.In order to install these plugins you must be connected to internet.

In available plugins,click reload catalog which will update available plugins.From the list select 
--web application
--Glassfish
--Css preview
 and install, it make take few minutes .After installation you need to restart Net beans IDE.

Now you are done. Go File>new project ,now you have option for JAVA web in category then select web application in project.click next,then give name for project and location for project to save.Then in next, select server from drop down list which is Glassfish that we installed before,you can add other server like tomcat instead.Select java EE version as java EE 6  and click finish.

Then you get  a project ,build and run it.As output you will get Hello World in web browser.

For css style builder and  preview window go window>other>css preview and css style builder.In order to  add css style to this hello world page go to File>new file,  there in Categories choose web and select Cascading  Style Sheet (CSS) as File type.So you get new page added to your project where you can add all your css style.
However you have to link this page with index.jsp page.For this go to index.jsp  which is HTML page with Hello World.Put this code inside the head tags 
i.e. <head > <link rel="stylesheet" type="text/css" href="mycss_name.css" /></head>
Then you are good to go.

No comments:

Post a Comment