Create Simple JSF project in Netbeans IDE
I am going to explain to ‘create simple and empty JSF1.2 project in Netbeans IDE‘.
Step 1: System Requirements
1. Netbeans IDE 6.7 or Advanced version
2. Tomcat server 6.0.29
Step 2: Create simple project name like ‘JSF1.2-Demo’
File → New Project → Java web → web application →
Project Name : JSF1.2-Demo
Project Location : Desired Location
Next – > Select server tomcat – Tomcat 6.0.29 (already you added in net beans)
Check : Net beans -> Service windows -> server -> Tomcat
If you didn’t add tomcat server, refer this
Add tomcat server into Netbeans IDE
Next → Select ‘Java Server Faces’ → Select libraries as ‘JSF1.2’ → Finish.
Step 3: You can see the following project structure in Netbeans project window
JSF1.2-Demo
→ web pages
→ META-INF
→ WEB-INF
welcomeJSF.jsp
→ configuration files
→ server resources
→ Source packages
→ Test Packages
→ Libraries
→ Test Libraries
Step 4: How to run this empty project
Right click the project ‘JSF1.2-Demo’ and Run.
Otherwise
Right click the project and select clean and build.
Now JSF1.2-Demo.war file automatically create in your project location
Ex (../../JSF1.2-Demo/dist/ JSF1.2-Demo.war
Step 5: Deploy war into tomcat.
1. Start tomcat service
2. http://localhost:8080/manager/html
3. Browse your war and deploy into tomcat
Step 6. Run your project:
http://localhost:8080/JSF1.2-Demo/
Now you can see the output
Welcome Java Server Faces
Add Tomcat server into Netbeans IDE
I am going to explain ‘how to add tomcat server into netbeans IDE?’.
Step 1: System Requirements
1.Net beans IDE 6.7 or Advanced version
2.Tomcat server 6.0.29 or Advanced version
Step 2: Install Net beans.
Step 3: Install Tomcat
Step 4:
a. Open Net beans IDE –> Select Service window -> Right click server -> Add server
b. Choose ‘Tomcat’ option -> Next
c. Browse your Tomcat installed location like (c:/…/Tomcat/)
d. If user name and password not created , then enter the username and password
e. Finish
Create and run simple java program
Write a simple java program and run java program has some steps. The steps are,
Step 1 : System Requirements
Download the latest jdk and install your pc desired location
For example : C:\Program Files
Step 2 : After install the jdk, check the javac file location.
Path : C:\Program Files\Java\jdk1.6.0_21\bin
Step 3 : Write a program using Notepad, WordPad. The file name is HelloWorld.java
public class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello World Program start...");
System.out.println("\nHello World\n");
System.out.println("Hello World Program end!!!");
}
}
Step 4 : Save java file. The file name must be equal to java class name.
Consider the program file location : F:\Studies\JAVA\Code
Step 5:Compile and Run program
Step 6 : Open command prompt
For example If the program location is : F:\Studies\JAVA\Code,
then using the following command
C:\..>f: F:\>cd studies F:\Studies>cd java F:\Studies\JAVA>cd code F: \Studies\JAVA\Code>
Step 7: Check the javac compile path is set or not:
F:\Studies\JAVA\Code>javac
a) If you get the following result after execute the command , then already javac path is set.
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
…
…
…
b) If you get the following result, then you must set javac path
'javac' is not recognized as an internal or external command, operable program or batch file.
c) Set javac path using the following command
F:Studeis\JAVA\Code>path="C:\Program Files\Java\jdk1.6.0_21\bin"
It means, that is javac location, which is used to compile java program
d) After path set, once again do the step 7 process
Step 8: Compile java program
F:\Studies\JAVA\Code>javac HelloWorld.java
Step 9: Run program
F:\Studies\JAVA\Code>java HelloWorld
Step 10: Output is :
Hello World Program start... Hello World Hello World Program end!!!
Apache Tomcat port information
I am giving the following information
1 . Tomcat port information
2 . Change Tomcat username and password
3 . Start , Stop and Restart tomcat
1 . Tomcat port information
C:/ …/Tomcat6.0/conf/server.xml
This file have default port number (During installation specified…) you can able to change that port number.
Server.xml
<?xml version='1.0' encoding='utf-8'?>
…
<Server port="8005" shutdown="SHUTDOWN">
…
…
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000"
redirectPort="8443" />
…
…
</Server>
The connector tags have your tomcat port number.
2 . Change the tomcat manger username and password.
If you want to change the tomcat username and password, then you edit the tomcat-user.xml file
<tomcat-users>
<role rolename="admin"/>
<role rolename="manager"/>
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="admin" password="admin123" roles="admin,manager"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>
Here I showed , changed tomcat admin username and password
The username : admin
The password : admin123
3. Start , Stop and Resart tomcat
If you have change (server.xml or tomcat-user.xml), then better you will restart your tomcat.
Restart Tomcat :
Start -> run -> services.msc -> Select Apache Tomcat -> Click Resart or stop,start in leftside.
4 : Check your username and password
Then Click TomcatManager and give username (admin) and password (admin123).
If successfully login, then username and password perfecltly set.
Otherwise, check tomcat-users.xml file.
Create simple JSP program using tomcat
Create and Run a simple JSP program using tomcat
Here I am going to explain for write create a simple jsp program and run that program in apache tomcat. This process has some steps. The following steps are based on windows operating system
Step 1: Download latest Apache Tomcat and install machine.
Example: The tomcat installed location (C:/Program Files/Apache Software Foundation/Tomcat 6.0/)
After installation, the tomcat folder has the following files are bin, conf, lib, logs, temp, webapps and work.
Step 2 : Create directory “myjsp” and “simple_programs” under the webapps
C:/ Program Files/Apache Software Foundation/Tomcat 6.0/webapps/myjsp/simple_programs
Step3 : Create simple jsp program. The program name as “helloworld.jsp”
<%--
Document : helloworld
Created on : Dec 20, 2010, 10:20:48 PM
Author : eswar
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<p> Hi, <h3><%="Hello!" %></h3></p>
<p>You successfully run a simple jsp program.</p>
<p>Learn More concept about jsp.</p>
</body>
</html>
Step 4: Save this file the following location :
C:/ Program Files/…/…/webapps/myjsp/simple_programs/helloworld.jsp
Step 5: Before run this code, know some details about tomcat.
apache-tomcat-port-information
Stpe 6: Run jsp program
a)Start the tomcat service
Start -> run -> services.msc -> Select Apache Tomcat -> start
b)Open new tab in browser or open new window :
http://localhost:8080/myjsp/simple_programs/helloworld.jsp
Now you will get the output as :
Hi, Hello!
You successfully run a simple jsp program.
Learn More concept about jsp.
My Favourite Forums
I am user of so many forums. The forums are :
JSF : http://community.jboss.org/people/eswaramoorthy1985
Web application : http://stackoverflow.com/users/331105/eswaramoorthynec
Java : http://www.coderanch.com/forums/user/profile/226639
Java Interview questions with answer
Here i give some url’s for download java interview questions with answers.
All questions got from various sites and
Answers are prepare from so many sites and Complete reference book.
It’s useful for fresher.
Url’s :
http://www.filezzz.com/183637/Eswar_Java_ Interview_Question_Answer.doc.html
http://www.filezzz.com/174828/Eswar_Java_%20Interview_Questions_Answer.doc.html
If cannot download the document, just comment here. I will send that document.
All the best.
Hello world!
Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!