rd22 February 2016

How to get ServletContext object in the data layer?

My application runs as 2 separate parts, the web module runs in the tomcat container and the data layer runs as a separate java program in a different service and they interact using the database.

I want to access the ServletContext in the data layer, how can I do this?

When I simply use the ServletContext in the data layer it gives me an exception NoClassDefFoundError.

Answers


rd22 February 2016

So I took @Kayaman's advice. And tried to limit the use of objects in their respective layers i.e. using context in the presentation layer and the Hibernate Session in the Data Access Layer.

I passed the call from the Controller to the DAO and store the needed objects in a global map in the DAO which were later called for further processiong. And finally returned the signals back to the Presentation layer.

Post Status

Asked in February 2016
Viewed 1,546 times
Voted 12
Answered 1 times

Search




Leave an answer