Mohammad Monis

Greenhorn
+ Follow
since Jan 04, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mohammad Monis

soumyaansh roy wrote:what are the significance of ServletContext and ServletConfig what kind of information we save in these 2 objects please give some practical examples , thanks


ServletConfig - parameter scope is limited to the scope of the servlet in which the parameter is defined. For example, shopping cart of a user is specific to a particular user so servletconfig params can be used.
ServletContext - parameter scope is application wide and the parameter can be use to store application session info/ application initialization parameters,etc not specific to a servlet.
12 years ago
org.apache.jackrabbit.rmi.client.ClientNode cannot be cast to net.fortuna.ical4j.model.Component - I didn't see anywhere in the servlet code that you are casting ClientNode to Componet. So the error might be coming from different code section. Can you share the line no. indicated in the error log at which the cast is failing.
12 years ago

wea sels wrote:Yes but what I would like to understand is ServletContext and ServletConfig are interfaces so how are config and context passed as objects??

http://www.java2s.com/Tutorial/Java/0400__Servlet/GetServletContextInitParameter.htm



objects can be type cast to the implementing interface.
12 years ago

wea sels wrote:Hi,
my question is ServletConfig and ServletContext are interfaces implemented by GenericServlet and HttpServlet classes so how can they have objects?
Like
ServletConfig config;
ServletContext context;

[Answer1] config/ context are the objects and are type casted to ServletConfig/ ServletContext which java permits

if they are interface references how can they be passed as objects
example : super.init(config);

[Answer2] Answers1 states that config/ context are the objects so perfectly legal to pass the objects

also if we use the above overriding statement
why is the following statement correct?

super.init(config);
ServletContext context=getServletContext();

what does it mean:: The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized.


I have gone through the docs but couldnt understand so i am posting here. Thanks

12 years ago
ServletConfig has servlet wide scope. It is defined inside <servlet> </servelet> in web.xml

ServletContext has application wide scope . It is defined outside the <servlet> tag in web.xml
12 years ago