wood burning stoves 2.0*
The moose likes Servlets and the fly likes doubts in servlets concepts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "doubts in servlets concepts" Watch "doubts in servlets concepts" New topic
Author

doubts in servlets concepts

Will Zelan
Ranch Hand

Joined: Apr 15, 2012
Posts: 56

hi to all professionals who are helping me to learning lot in this forum,i need to know about servlet context interface and servlet config interface, i know the definition but i want to know how it works or used on servlet practically
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

A forum is not a suitable substitute for a tutorial or the documentation. Have you read the javadoc entries for those classes? If so, what specific question do you have regarding them?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Niraj Jha
Ranch Hand

Joined: Feb 20, 2013
Posts: 63

ServletContext is whole application based(common for all servlets inside an application), any attribute you want to be available on application level we set it into servletcontext.Although servletconfig is individual to one servlet.Take an example :

App1->four servlets

ServletContext-1
ServletConfig -4

ServletConfig contains individual servlet name ,their parameters declared inside <init-param> of web.xml.For more check ServletContext,ServletConfig
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
Niraj Jha wrote:ServletContext is whole application based(common for all servlets inside an application), any attribute you want to be available on application level we set it into servletcontext.Although servletconfig is individual to one servlet.Take an example :

App1->four servlets

ServletContext-1
ServletConfig -4

ServletConfig contains individual servlet name ,their parameters declared inside <init-param> of web.xml.For more check ServletContext,ServletConfig

actually i know the definition of both interfaces servlet context-we can acess data from its environment,it is common to all servletes,we can share information through servlet context,even we can use this in request dispatcher
servlet config-to pass initilization information from deployment descriptor to servlet via init() method'
i need practically with example how it works or useful in servlets
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
Bear Bibeault wrote:A forum is not a suitable substitute for a tutorial or the documentation. Have you read the javadoc entries for those classes? If so, what specific question do you have regarding them?

i know its forum for discussion about to related topics,i know concepts but i have regarding queries based on the concepts which i tried to clarify my doubts and develop in code
Niraj Jha
Ranch Hand

Joined: Feb 20, 2013
Posts: 63

If you know everything then what is your doubt?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

sekhar kiran wrote:
Bear Bibeault wrote:A forum is not a suitable substitute for a tutorial or the documentation. Have you read the javadoc entries for those classes? If so, what specific question do you have regarding them?

i know its forum for discussion about to related topics,i know concepts but i have regarding queries based on the concepts which i tried to clarify my doubts and develop in code

Again, what specific questions do you have? Just saying "I want to know about it" is not enough to give an answer to.
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
Niraj Jha wrote:If you know everything then what is your doubt?

i mean how we can use in servelt both interface?what kind of situation, iam expecting if you provide any simple example it will be a very useful then i will catch you
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
any one can post any examples
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi, as Bear Bibeault said your topic is generic and you must post a more specific question, but I give you a generic answer and example, The ServletConfig is a interface that have methods to get information releted only to the servlet, as its name, and init parameters. The ServletContext is a more generic interface is as an ApplicationContext, it's generic for the whole application, with this interface you can get the global init parameters set an get attributes that are visible for the all application, and more. I give you an example.


I hope this help you
Kind regards
Cesar


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Cesar Loachamin wrote:Hi, as Bear Bibeault said your topic is generic and you must post a more specific question

I was not directing that to you. I want to know what specific questions the OP has. As I've said, just asking a vague question about a subject is better answered by a tutorial than a forum post.
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
Cesar Loachamin wrote:Hi, as Bear Bibeault said your topic is generic and you must post a more specific question, but I give you a generic answer and example, The ServletConfig is a interface that have methods to get information releted only to the servlet, as its name, and init parameters. The ServletContext is a more generic interface is as an ApplicationContext, it's generic for the whole application, with this interface you can get the global init parameters set an get attributes that are visible for the all application, and more. I give you an example.


I hope this help you
Kind regards
Cesar

hi thanks for reply,actually your giving logic ,but iam looking for practically i mean if we use servlet config what is useful and how it collects param name and values,if i execute the program i will got the logic,what have to provide in web.xml and how to use servlet cofig,if i exceute it iwill understand
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
is servlet and jsp is interface or class?how do you check api like in core java javap java.util.ArrayList
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
See http://docs.oracle.com/javaee/6/api/. If you look through the methods in javax.servlet.ServletConfig and javax.servlet.ServletContext it should become clear why they're useful (just ask yourself: if method X wasn't there, how would I accomplish what it does?).

I agree with Bear that working through a Servlet/JSP introduction or tutorial would probably serve you better at this point; you seem to have fundamental questions about these topics than can't be explained in a forum discussion like this.


Ping & DNS - my free Android networking tools app
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
Ulf Dittmer wrote:See http://docs.oracle.com/javaee/6/api/. If you look through the methods in javax.servlet.ServletConfig and javax.servlet.ServletContext it should become clear why they're useful (just ask yourself: if method X wasn't there, how would I accomplish what it does?).

I agree with Bear that working through a Servlet/JSP introduction or tutorial would probably serve you better at this point; you seem to have fundamental questions about these topics than can't be explained in a forum discussion like this.

now i understand about servlet config and sevlet context, how to see java api like if we type in command javap java.lang.String means it shows full details like the way for jsp and servlets
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

sekhar kiran wrote: how to see java api like if we type in command javap java.lang.String means it shows full details like the way for jsp and servlets

Add the JEE Javadoc to the IDE you are using.


SCJP, SCWCD.
|Asking Good Questions|
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
Amit Ghorpade wrote:
sekhar kiran wrote: how to see java api like if we type in command javap java.lang.String means it shows full details like the way for jsp and servlets

Add the JEE Javadoc to the IDE you are using.

i cant understand what are you trying to say, is it possible to check java api in command like core java
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You can use javap on any class at all, if that's what you're asking. Just specify your classpath to include the class you wanted to disassemble. I'm not sure why you would want to do that, but then again perhaps that wasn't what you were asking. To tell the truth I couldn't really tell what your question was.
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
Paul Clapham wrote:You can use javap on any class at all, if that's what you're asking. Just specify your classpath to include the class you wanted to disassemble. I'm not sure why you would want to do that, but then again perhaps that wasn't what you were asking. To tell the truth I couldn't really tell what your question was.

yeah , here my doubt is how to see in servlet and jsp ,is they are all interface,iam trying this in command like javap javax.servlet.ServletConfig or javap javax.servlet.HttpServlet it shows error ERROR:Could not find javax.http.ServletConfig
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

sekhar kiran wrote:it shows error ERROR:Could not find javax.http.ServletConfig

That is because the class was not found in the classpath.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

It seems kind of pointless to spend time trying to run javap on those interfaces when the API documentation gives you the same information as javap and a lot more.
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
Paul Clapham wrote:It seems kind of pointless to spend time trying to run javap on those interfaces when the API documentation gives you the same information as javap and a lot more.
i think your mentioning link which provided in previous post,i just want to know is it possible to see javaapi in command like what we seen in core java(example string,stringbuilder,collections)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
That has already been answered with "yes", and it has been pointed out to you why it doesn't work the way you are doing it. Please take the time to read and understand what the people who are trying to help you are writing.
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
Amit Ghorpade wrote:
sekhar kiran wrote:it shows error ERROR:Could not find javax.http.ServletConfig

That is because the class was not found in the classpath.

ok so what is the correct command to get it
sekhar kiran
Ranch Hand

Joined: Apr 25, 2013
Posts: 84
Ulf Dittmer wrote:That has already been answered with "yes", and it has been pointed out to you why it doesn't work the way you are doing it. Please take the time to read and understand what the people who are trying to help you are writing.

so whats the correct command to see the details
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Here's a link to the javap documentation: http://docs.oracle.com/javase/6/docs/technotes/tools/windows/javap.html
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

sekhar kiran wrote:so whats the correct command to see the details

javap
 
Consider Paul's rocket mass heater.
 
subject: doubts in servlets concepts
 
Similar Threads
Can We extend a java class or interface in a JSP page
Implementing Interface in JSP
servlet api using facade design pattern is it right?
Static & Class Variables
in which interface or class the method service(request, response) is present?