Struts2 Hello World in Eclipse

Struts2 Hello World Example in Eclipse

Below Example use struts2.3.X version

Project Structure

Strut2 Hello File Structure

—index.jsp—

 

—HelloWorld.jsp—

 

—web.xml—

 

—struts.xml—

 

—HelloWorldAction.java—

 

—MessageStorage.java—

 

—pom.xml—

 

—OUTPUT—

 Struts2 Hello World

 

Download Struts2 Hello Program

 

Source: http://struts.apache.org/release/2.3.x/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html

JSTL Tags in Jsp

JSTL is stands for JSP – standard Tag Library

JSTL gives the collection of jsp tags that are very useful if you are not using any framework like Struts2.

File Structure

jstl_file_structure

Example

—index.jsp—

—link.jsp—

Download jstl.jar

 
OUTPUT

jstl_index

 

Download JSTL Hello Example

 

First Java Program using Notepad

You can write Java program using any IDE like Netbeans, Eclipse etc or you can directly write Java program using Notepad and can compile using CMD (command prompt)

text_x_java
 

Let’s write the First Java Program using Notepad

Step 1. Create a text document with name Hello.java

Step 2. open the created file and write the following code

 

Hello.java

 

Now open the CMD

Go to the path where your Hello.java is kept then give the file name to compile it

javac

 

You can see the command javac Hello.java

Here by this command we are calling java compiler to compile Hello.java file

Now press enter and this creates a new file with name Hello.class

To run the file type java Hello i.e. java <Class Name>

run

Note: You have to set the path first to run the java program if your program is any where except bin folder.

Hibernate and Java hello example

Step 1:  Open netbeans
File> New Project >java web> web application .click next
Project name : hibernatehello .click next . again click nextnow select framework : hibernate . click finish

Step 2: Now hibernate.cfg.xml file opens edit this line change the database name if required in am using hibernate 

after edit:

make sure that this database should exists 
complete code of hibernate.cfg.xml

Step 3:
Make a java class named student and copy the below code.(Student.java)

Step 4:
Now right click on the folder and select hibernate mapping wizard
File Name: student.hbm .click next


class to map: one.Student .click finish
code in student.hbl

Step 5:
Again right click on package “one” select HibernateUtil.java
name this class as HibernateUtil and just click finish.
now last step:
copy this code in index.jsp