How to create a website using java
Is it possible to make a website in java? No, you can not make or developed website using java but it can be done using one of the technology in Java know as JavaServer pages (JSP). JavaServer pages are technology released in earl 1999 by Sun Microsystems which is similar to PHP and ASP but is uses Java as its basic programming language. JSP is used to craft dynamic webpages stand on different documents type like HTML, XML, etc.
Create a website using java
For beginner’s we are using the word Java but in actual web pages are generated using JSP as I already tell about JSP in details. So, never search for “Create a website using java” instead you have to search as “Create website using Java Server Pages (JSP)”.This is the very simplest way to use JSP for creating the website in Java.You can develop dynamic web pages in JSP as it allows you to embed HTML in Java code files.For creating the website in Java you needs to have Servlet Container, Tomcat is the most popular and free Servlet Container provided by Apache Software Foundation.
Web development in java
Go through the following steps:
- The very first step for web development using JSP is to have an IDE and Server, you can have any IDE i.e Eclipse,NetBeans etc, I am having Eclipse.For this just go to the official site of particular IDE and download the setup file and install it.For Server use Apache Tomcat you can use any version of it one which I have used is 7.0.11.
2. Once you done with the first step, setup Tomcat inside the Eclipse so that you can control the start or stop of the server from IDE. For this open up the Eclipse IDE select Window -> Show View -> Server. Server tab will appear at the bottom.
3. Right click on Server tab -> New -> server.
4. Now select the installed version of Apache Tomcat by extending Apache directory -> Next -> hit “Browse” for selecting Tomcat installation directory and select it.Also select the JRE from the JRE drop down list as Tomcat requires only JRE and hit “Next” -> “Finish”.
Tomcat setup in the IDE is done here now you can see a Server node in the Project Explorer.
5. Right click on Server tab and select “start” you will see a “Console” tab with message “Server Startup in 417(depends on machine) ms”
6. Now create a web application project for this go to Project Explorer right click->New->Other->Web->Dynamic Web Project->Next->now give a project name ->Next-> select src ->Next ->Check the check box for create web.xml->Finish->Yes.
7. Go to the Window->Show View->Navigator->From Project Explorer select the newly created project->WebContent->WEB-INF->web.xml (it will show design view go to the source view from a left bottom corner) this will show the default files names that will open by the system wen the project will run.Initially, we do not have any of these files so we need to create any of it first.
8. Right click on WebContent->New->other->web->HTML file->NEXT->give a file name as the name of any of the default file.I gave “index.html” and select the WebContent folder->NEXT->Finish.This will create the index.html file now make changes to the file as per you choice.
9. Remove all the default files from “web.xml” file except “index.html” as we have created it.
10. Save it.and run it by right clicking on the project from Project Explorer-> Run As->run on Server->Select the Apache Server wich you have created(You can select other as well)->NEXT->Finish.
Now the browser tab will open inside the Eclipse itself and you can see that the webpage that you have just created in “index.html” runs there.So here you have created a webpage in Java.