0% found this document useful (0 votes)
3 views7 pages

Adv Java Lab Instructions N Assignments

The document outlines a 12-day training program focused on advanced Java, covering topics such as MySQL database setup, servlet life cycle, session tracking, JSP syntax, Hibernate integration, and Spring dependency injection. Each day includes specific tasks, readings, and assignments to reinforce learning and practical application. The program emphasizes hands-on exercises and project work to solidify understanding of Java EE technologies and frameworks.

Uploaded by

rahulbadhe630
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Adv Java Lab Instructions N Assignments

The document outlines a 12-day training program focused on advanced Java, covering topics such as MySQL database setup, servlet life cycle, session tracking, JSP syntax, Hibernate integration, and Spring dependency injection. Each day includes specific tasks, readings, and assignments to reinforce learning and practical application. The program emphasizes hands-on exercises and project work to solidify understanding of Java EE technologies and frameworks.

Uploaded by

rahulbadhe630
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

Day 1

1. Confirm that MySql DB is working fine , using cmd prompt OR mysql workbench

2. Refer , to installation instructions , shared on 1st day of core Java.


2.1 JDK version : JDK 11
2.2 IDE : Eclipse STS 3.9.18
2.3 Create NEW workspace , for advanced java.
2.4 AS per the instructions : in "day1-data\day1_help\readmes\Installation steps
for Tomcat.txt" add Apache Tomcat web server.
2.5 Confirm if it's starting properly , without any exceptions
2.6 Create dynamic web app n test index.html

3. Extract Java EE docs from : "Advance Java Software n Help\\


web_prog_prerequisites\softwares n docs\javaee-api-8.0-javadoc.jar"

4. In index.html , add a link to test the servlet , deployed using annotations


(Servlet1)

5. In index.html , add another link to test the servlet , deployed using xml tags
(Servlet2)

Servlet1 should be loaded eagerly


Servlet2 should be loaded lazily

Confirm complete servlet life cycle


(by printing messages on the server console)

In individual labs , revise all of today's work .


Go through :readme Java EE.txt
If time permits :
1. Create advjava db in mysql
Solve, using DB layered approach(Tester, DAO , DBUtils ,POJO,DB)

User signin
Steps
1.Tables : users
2. POJOs : User (voting status : boolean)
3 Create DBUtils: edit DB user name n pwd
openConnection :
closeConnection

4. DAO
4.1 UserDao
User authenticateUser(String email,String pwd) throws SqlException
4.2 Implementation class
5. Write a tester for testing this
(main class n not a servlet !)

Day 2
1. import day2.1 as existing project in your workspace
(Edit DBUtils as per your DB settings)

Revise
1.1 Servlet-JDBC integration
1.2 Page Navigation : redirect scenario
(MJUST check the net traffic: inspect option)

2. Hands on
Add a Cookie to perform session tracking.

3. MUST solve : New Voter registration


Add a link on login.html , New Voter
Clicking on link , show Voter registration form
Think about which request data , you will add in the form ?
Options : id , first_name , last_name , email , password , dob ,
status , role
Submit it to RegisterVoterServlet
Here you add a validation rule.
Voter's age > 21 . If yes insert voter details in DB (using DAO n POJO , DBUtils)
Otherwise , give suitable error mesg.

Reading exercise
1. day2-data\day2_help\readmes\regarding HttpServlet.txt
2. day2-data\day2_help\page navigation\page navigation techniques.txt
(only client pull)
3. day2-data\day2_help\session tracking\regarding session tracking.txt
(till cookie based session tracking)

Today's sequence.txt , will tell you what all we did today!

Day 3
MANDATORY REVISION
1. import day3.1 as existing project in your workspace
(Edit DBUtils as per your DB settings)
Revise
1.1 Servlet life cycle
1.2 Redirect
1.3 Session Tracking using HttpSession
1.4 Dynamic form generation in Candidate List page

2.OPTIONAL assignments
2.1 New User registration (discussed yesterday)
2.2 Complete admin flow of the online voting assignment
2.3 IPL Player selection assignment

Without taking pressure , try to solve any of above assignment , to get servlet
practice.

Day 4
1. import day4.1 as existing project in your workspace (student admission w/o DB)
Revise RequestDispatcher's forward scenario

2. import day4.2 as existing project in your workspace (student admission w/o DB)
Revise RequestDispatcher's include scenario

3. import day4.3 as existing project in your workspace (online voting : voter's


flow)
What will you edit ? DBUtils or web.xml ???
3.1 ServletConfig
3.2 Revise entire servlet life cycle , in detail , including executor frmwork +
servlet config
3.3 Web app listeners

4. MUST solve any of the assignments , discussed earlier.


Servlet IPL assignment
steps
1. Copy teams n players tables in the DB
2. Create Team n PLayer POJO.
3. Copy your own working DBUtils under src/main/java (under utils pkg)
4. Create DAO layer
4.1 For the 1st page : get team id n abbreviation from all the teams
List<Team> getSelectedDetails() throws SQLException

4.2 Add a servlet to generate dynamic form , for adding player details
dynamic part : options in the drop-down list.

eg URL after adding a player :

http://localhost:8080/day4_ipl/process_form?
team_id=2&full_name=Virat+Kohli&dob=2000-11-28&avg=78&wickets=10

5. Mandatory reading exercise


5.1 "day4-data\day4_help\readmes\page navigation techniques.txt"
5.2 "day4-data\day4_help\diagrams\page navigation summary.png"
5.3 "day4-data\day4_help\diagrams\servlet life cycle in detail.png"

Day 5
1. import day5.1 in your workspace n revise basic JSP synatax
scripting elements , EL syntax n page directive err handling attributes.

2. Solve student admission assignment in JSP

3. Complete IPL assignment in servlet.

Day 6
1. import day6.1 in your workspace n revise
1.1 include directive
1.2 forward n include actions

2. import day6.2 in your workspace n revise


JSP using Java Beans
Layers involved : JSP --- Java Bean --- DAO (uses DBUtils) -- POJO --DB

3. MANDATORY Solve
IPL 1st page (at least!) using JSP n Java Bean n DAO (uses DBUtils) -- POJO --DB

4. In the individual labs , with internet connection :


EVERYONE MUST import the hibernate template project , as existing Maven Project :
"day6_data\day6_help\hibernate help\template project\test_hibernate_basic"
to download all hibernate dependencies
(You WON'T be able to work tomorrow , with hibernate otherwise!)

Day 7
Wait for instructions please !

1. If you have not imported , import "test_hibernate_basic" as existing maven


project
1.1 Test bootstrapping of hibernate
1.2 Auto creation of Table
1.3 insertion of the record.

2. Continuation of IPL assignment : if time permits !


Day 8

1. import day8.1 in your workspace , as existing maven project


Edit hibernate.cfg.xml , as per your db user name n password

2. Mandatory assignment (you can continue in the same as day8.1 or day7_lab,


completely your choice)

2.1
Create Student pojo
properties :
studentId : Integer (PK) ,first name , last name,email,password,course(enum with
admission fees), dob : LocalDate
Add JPA annotations
Add <mapping> entry
Test proper creation of "students" table.
Refer to our Employee POJO for annotations.

2.2
Solve this
1. Student registration (ids should start from 1001 onwards, HOW will you achieve
it ????)
After creating the students table
alter table students auto_increment 1001
i/p : student details (first name , last name,email,password,course(enum),dob )
o/p : Reg successful , with student id(auto generated from hibernate, 1001 onwards)

or failure mesg.

2. Student login
i/p : email , password
o/p : A mesg : login successful , with student details lifted from db
or failure mesg.
Hint : JPQL -- createQuery , setParams: 2, getSingleResult

3. Get all students from a specific course


i/p : course name
Display list of students from the course
Hint : jpql ,createQuery , setParam: 1, getResultList

4. Change course
i/p : student id(int) , course name
o/p : in case of invalid id --error mesg
in case of success : course updation message
Hint : session.get(...) -->null chking --not null --> persistent student
set new course
------------------

Maven Clean Up instructions (If the project is not working properly!!)


1. Force update the project
R Click on project --Maven --Update Project (Force update it!)

2. If you are having problems still , in downloading the Maven hibernate


dependencies ,
Use Maven clean option n Project clean

3. Worst case , if it still doesn't work


Exit STS IDE
Delete maven <repository> folder
Enter STS
Force update Maven project

Day 9
1. Complete pending work of Day 8.

2. import day9.1 , to revise


2.1 save vs persist
You can replace persist by saveOrUpdate or later merge n spot the differences
(Refer to readme : hibernate session api)
2.2 Bulk updation
2.3 session.delete
2.4 Solve
Delete details of all emps of specified employment type
(via Bulk delete)
i/p : employment type
o/p : a mesg indicating success or failure

3. import day9.2 to revise (MUST)


one to many bi dir association between the entities
Department 1<---->* Employee

4. Optional BUT Recommended for your clarity n confidence


Author 1<----->* Book
Use BaseEntity n try @MappedSuperclass

Tables to be generated by hibernate (books n authors)

4.1 Author :id first name ,last name , email(unique) , pwd + ???????
Book : id,title(unique), price + ?????

4.2 Do not add any mapping related annotations n observe the exception
4.3 Fix the problem
4.4 Hibernate will generated an additional table.
Why ??
How to generate only 2 tables : (books n authors)

4.5 FK column name should be : author_id


How ?

4.6 Add dao layers n tester for the following


1. Add new Author
i/p : author details
o/p : a mesg

2. Add a book written by an author


i/p : book details + existing author email
o/p : a mesg

3. To test cascading
i/p : new author details + 3 new book details
o/p : a mesg

Day 10
1. Revise JPA associations
Highlights :
one to many bi dir associaton (mappedBy , orphanRemoval n fetch type)

one to one uni dir mapping (@MapsId)

Mandatory Hands on
2. Integrate web app + hibernate
(import template project : web_maven_hibernate)
I hope it's already done!
Layers : JSP --Java Bean --Hibernate based DAO --HibernateUtils --Entities --DB

Solve : IPL assignment


(Refer to day6_ipl)
We had done it with JSP-JB , but with JDBC based DAO n oridinary POJOs
We are going to port it to hibernate + web app

3. OPTIONAL
3.1 Cascade on update
Change dept location n change salary of emps

3.2 Display all department details


(Before that set fetch type as eager)
Observe : select n+1 issue

3.3 Display all employees from a specific city


i/p : city
o/p : list of emps

Day 11
1. Continue with IPL assignment n complete it!
1.1 Write a test case for the DAO layer
1.2 Complete Java Bean n JSP

Hints for Completion of IPL assignment


1. Example URL after submitting the form :
http://localhost:8080/day10_lab/process_form.jsp?myTeam=2&fn=a&fn=b&dob=1999-06-
13&avg=56.78&wickets=10

2.Add a method in Team DAO to fetch selected team details


Team getTeamDetails(long teamId);

3. In IPLBean class
3.1 Add bean properties having MATCHING names with request params
(choose correct data types)
3.2 Add getters n setters for every property
3.3 Add a B.L method to first validate n add player
eg : public String validateAndAddPlayer() {
Parse the props (eg dob)
Invoke validation rule/s --in case success --invoke dao's method to add the player
n return success mesg to the caller.
o.w : return err mesg to the caller.
}

4. In process_form.jsp
<jsp:setPropert property="*" name="ipl"/>
n invoke B.L method of IPL bean using EL syntax.
2. BLOB handling (Ref : sequence of day9_data\day9_help)
2.1 Store emp image in DB
i/p : emp id n image file path

2.2 ReStore emp image in DB


i/p : emp id n o/p image file path

3. Session's get vs load methods


Ref : Today's diagrams

4. Optional work :
You can either test it using testers or test case(@Test)

Launch new project


Assign emp to the project
list all emps from a project
Remove emp from the project
list all projects for the emp

Day 12
1. import day12.1 , as EXISTING MAVEN PROJECT , in your workspace.
Maven update .
Revise spring bean life cycle n explicit setter based DI

2. import day12.2 , as EXISTING MAVEN PROJECT , in your workspace.


Maven update .
Revise explicit constructor based DI

3. import day12.3 , as EXISTING MAVEN PROJECT , in your workspace.


Maven update .
Revise explicit factory method based DI

4. import day12.4 , as EXISTING MAVEN PROJECT , in your workspace.


Maven update .
Revise (implicit) automatic wiring byName

5. import day12.5 , as EXISTING MAVEN PROJECT , in your workspace.


Maven update .
Revise (implicit) automatic wiring byType

6. import day12.6 , as EXISTING MAVEN PROJECT , in your workspace.


Maven update .
Revise (implicit) automatic wiring constructor

You might also like