8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 17
About
Disclaimer
564Subscribers 237Fans 70Followers
Home
Oracle ADF
Java
Spring
NET
News
Join Us
4
Calling Servlet from Servlets in Java
Vinay 02 Mar 2011 Java servlets Views 6554 views
I gathered information from environment and sharing you this information with all
When Ever you want to call any servlet from another servlet We can use two ways-
A servlet can make an HTTP request of another servlet Opening a connection to a URL
A servlet can call another servletrsquos public methods directly if the two servlets run within the same
server
I will let you know the second way to calling the servlet To call another servletrsquos public methods directly
you must
You Should know the name of servlet that you want to call
Acquire access to that servletrsquos Servlet object
Calling the servletrsquos public method
To get the object of servlet use the ServletContext objectrsquos getServlet method Get the ServletContext
object from the ServletConfig object stored in the Servlet object An example should make this clear
When the EmployeeDetail servlet calls the BookDB servlet the EmployeeDetail servlet obtains the
EmployeeDB servletrsquos Servlet object like this
Once you have the servlet object you can call any of that servletrsquos public methods For example the
EmployeeDetail servlet calls the EmployeeDB servletrsquos get getEmployeeDetail method
You Should take care of the few thingsIf your servlet is following the singlethreadedModel interface then
your call violate that single threaded model Then you should implement the first way
983152983157983138983148983145983139 983139983148983137983155983155 983109983149983152983148983151983161983141983141983108983141983156983137983145983148 983141983160983156983141983150983140983155 983112983156983156983152983123983141983154983158983148983141983156 983163 983152983157983138983148983145983139 983158983151983145983140 983140983151983111983141983156 (983112983156983156983152983123983141983154983158983148983141983156983122983141983153983157983141983155983156 983154983141983153983157983141983155983156983084983112983156983156983152983123983141983154983158983148983141983156983122983141983155983152983151983150983155983141 983154983141983155983152983151983150983155983141)983156983144983154983151983159983155 983123983141983154983158983148983141983156983109983160983139983141983152983156983145983151983150983084 983113983119983109983160983139983141983152983156983145983151983150983163
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 27
Vinay
I am software professional working on JavaJ2EEADF technologies ie
JavaJ2eeOracle ADFhibernateJ2eePLsqlApps for 5+ yearsI am
passionate about learning new technologiesI am sharing my knowledge Give
your views and suggestion on vinay[at]techartifactcom
More Posts - Website
Follow Me
29 Votes
Related Posts
creating a basic skeleton to invoke an AM in Java Class in Oracle ADF
01 Feb 2013
Java program to SORT MAP based on KEYS
08 Jan 2013
Why use hashMap when ConcurrentHashMap is therehellip | Techartifact
12 Dec 2012
4 Responses to Calling Servlet from Servlets in Java
MirkoMar 02 2011
Why donrsquot you use a RequestDispatcher
1
983086983086983086983109983149983152983148983151983161983141983141983108983106983140983137983156983137983138983137983155983141 983101 (983109983149983152983148983151983161983141983141983108983106)983143983141983156983123983141983154983158983148983141983156983107983151983150983142983145983143()983086983143983141983156983123983141983154983158983148983141983156983107983151983150983156983141983160983156()983086983143983141983156983123983141983154983158983148983141983156(983141983149983152983148983151983161983141983141983140983106)983099983109983149983152983148983151983161983141983141983108983141983156983137983145983148 983138983140 983101 983140983137983156983137983138983137983155983141983086983143983141983156983109983149983152983148983151983161983141983141983108983141983156983137983145983148983155(983141983149983152983113983140)983099983086983086983086983165983165
0
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 37
reply
Pravin Jain
Mar 02 2011
The method getServlet has long been deprecated for security reasons and will not give direct
access to a Servlet you may however use the getnamedDispatcher method to get a
RequestDispatcher and then forward to it
reply
Ricky
Aug 16 2011
A bit surpisred it seems to simple and yet useful
reply
2
Misterz
Mar 17 2011
As already said getServlet is deprecated other than call in HTTP or using RequestDispatcher that
are clean method of invocation itrsquos possible to use the same aim of using public method you can
use ServletContexthellip
Example
interface EmployDAO
Employee findById(String id)
hellip
MyServlet implements EmployeeDAO
init()
getServletConfig()
getServletContext()
setAttribute(ldquoEMPLDAOrdquothis)
MyOtherServlet
public void doGet (HttpServletRequest request
HttpServletResponse response) throws ServletException IOException
3
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 47
hellip
EmployeeDAO dao = getServletConfig()
getServletContext()
getAttribute(ldquoEMPLDAOrdquo)
Employee empl = daofindById(requestgetParameter(ldquoE_IDrdquo))
hellip
but i think itrsquos not so cleanhellip
BYE
reply
Leave a Reply
Name ()
Email (will not be published) ()
Website
Web Pag
You have tried to access a web page
which is in violation of your internet
usage policy
URLgoogleadsgdoubleclicknetpagead
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 57
Archives
Top Post
Thread Pool in java - 122281 views
Implementation of thread Pool in java - 44349 views
Oracle ADF interview Question Part ndash 1 - 40108 views
Serialization Vs Externalization - 36453 viewsAnonymous Classes in Java - 35272 views
What is Ext-Js(Extended JavaScript) - 31741 views
Interview question on thread in Java - 30427 views
Interface vs Abstract Class - 29911 views
Marker interface in java - 29040 views
Hello World Tutorial in ADF - 23440 views
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 67
Tags
ADF ajax ASPNET ASPNET 20 CNET CNET 20 code example column Design Pattern
Example extjs features get hashmap hibernate J2EE Java Java design Pattern Javascript Jetspeed2 Jquery
JSF JSF 20 lifecycle managed bean Memory method Microsoft Mysql Open Portal Open Source
Oracle ADF portal programmatically row Spring sql server table Task flow Techartifact Tips value
view object Web Development XML
Go To Top
Copyright 2009-2012 Techartifactcom
Disclaimer
About
You have tried to
access a web page
which is in
violation of your
internet usage
policy
URL
googleadsgdoublecl
adsclient=ca-
pub-7884501643823
output=htmlamp
h=600amp
slotname=25241005
w=160amp
lmt=1360750991amp
flash=114402amp
url=http3A2F
2Fwwwtechartifac
servlet-
from-servlets-
in-javahtmlamp
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 77
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 27
Vinay
I am software professional working on JavaJ2EEADF technologies ie
JavaJ2eeOracle ADFhibernateJ2eePLsqlApps for 5+ yearsI am
passionate about learning new technologiesI am sharing my knowledge Give
your views and suggestion on vinay[at]techartifactcom
More Posts - Website
Follow Me
29 Votes
Related Posts
creating a basic skeleton to invoke an AM in Java Class in Oracle ADF
01 Feb 2013
Java program to SORT MAP based on KEYS
08 Jan 2013
Why use hashMap when ConcurrentHashMap is therehellip | Techartifact
12 Dec 2012
4 Responses to Calling Servlet from Servlets in Java
MirkoMar 02 2011
Why donrsquot you use a RequestDispatcher
1
983086983086983086983109983149983152983148983151983161983141983141983108983106983140983137983156983137983138983137983155983141 983101 (983109983149983152983148983151983161983141983141983108983106)983143983141983156983123983141983154983158983148983141983156983107983151983150983142983145983143()983086983143983141983156983123983141983154983158983148983141983156983107983151983150983156983141983160983156()983086983143983141983156983123983141983154983158983148983141983156(983141983149983152983148983151983161983141983141983140983106)983099983109983149983152983148983151983161983141983141983108983141983156983137983145983148 983138983140 983101 983140983137983156983137983138983137983155983141983086983143983141983156983109983149983152983148983151983161983141983141983108983141983156983137983145983148983155(983141983149983152983113983140)983099983086983086983086983165983165
0
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 37
reply
Pravin Jain
Mar 02 2011
The method getServlet has long been deprecated for security reasons and will not give direct
access to a Servlet you may however use the getnamedDispatcher method to get a
RequestDispatcher and then forward to it
reply
Ricky
Aug 16 2011
A bit surpisred it seems to simple and yet useful
reply
2
Misterz
Mar 17 2011
As already said getServlet is deprecated other than call in HTTP or using RequestDispatcher that
are clean method of invocation itrsquos possible to use the same aim of using public method you can
use ServletContexthellip
Example
interface EmployDAO
Employee findById(String id)
hellip
MyServlet implements EmployeeDAO
init()
getServletConfig()
getServletContext()
setAttribute(ldquoEMPLDAOrdquothis)
MyOtherServlet
public void doGet (HttpServletRequest request
HttpServletResponse response) throws ServletException IOException
3
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 47
hellip
EmployeeDAO dao = getServletConfig()
getServletContext()
getAttribute(ldquoEMPLDAOrdquo)
Employee empl = daofindById(requestgetParameter(ldquoE_IDrdquo))
hellip
but i think itrsquos not so cleanhellip
BYE
reply
Leave a Reply
Name ()
Email (will not be published) ()
Website
Web Pag
You have tried to access a web page
which is in violation of your internet
usage policy
URLgoogleadsgdoubleclicknetpagead
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 57
Archives
Top Post
Thread Pool in java - 122281 views
Implementation of thread Pool in java - 44349 views
Oracle ADF interview Question Part ndash 1 - 40108 views
Serialization Vs Externalization - 36453 viewsAnonymous Classes in Java - 35272 views
What is Ext-Js(Extended JavaScript) - 31741 views
Interview question on thread in Java - 30427 views
Interface vs Abstract Class - 29911 views
Marker interface in java - 29040 views
Hello World Tutorial in ADF - 23440 views
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 67
Tags
ADF ajax ASPNET ASPNET 20 CNET CNET 20 code example column Design Pattern
Example extjs features get hashmap hibernate J2EE Java Java design Pattern Javascript Jetspeed2 Jquery
JSF JSF 20 lifecycle managed bean Memory method Microsoft Mysql Open Portal Open Source
Oracle ADF portal programmatically row Spring sql server table Task flow Techartifact Tips value
view object Web Development XML
Go To Top
Copyright 2009-2012 Techartifactcom
Disclaimer
About
You have tried to
access a web page
which is in
violation of your
internet usage
policy
URL
googleadsgdoublecl
adsclient=ca-
pub-7884501643823
output=htmlamp
h=600amp
slotname=25241005
w=160amp
lmt=1360750991amp
flash=114402amp
url=http3A2F
2Fwwwtechartifac
servlet-
from-servlets-
in-javahtmlamp
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 77
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 37
reply
Pravin Jain
Mar 02 2011
The method getServlet has long been deprecated for security reasons and will not give direct
access to a Servlet you may however use the getnamedDispatcher method to get a
RequestDispatcher and then forward to it
reply
Ricky
Aug 16 2011
A bit surpisred it seems to simple and yet useful
reply
2
Misterz
Mar 17 2011
As already said getServlet is deprecated other than call in HTTP or using RequestDispatcher that
are clean method of invocation itrsquos possible to use the same aim of using public method you can
use ServletContexthellip
Example
interface EmployDAO
Employee findById(String id)
hellip
MyServlet implements EmployeeDAO
init()
getServletConfig()
getServletContext()
setAttribute(ldquoEMPLDAOrdquothis)
MyOtherServlet
public void doGet (HttpServletRequest request
HttpServletResponse response) throws ServletException IOException
3
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 47
hellip
EmployeeDAO dao = getServletConfig()
getServletContext()
getAttribute(ldquoEMPLDAOrdquo)
Employee empl = daofindById(requestgetParameter(ldquoE_IDrdquo))
hellip
but i think itrsquos not so cleanhellip
BYE
reply
Leave a Reply
Name ()
Email (will not be published) ()
Website
Web Pag
You have tried to access a web page
which is in violation of your internet
usage policy
URLgoogleadsgdoubleclicknetpagead
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 57
Archives
Top Post
Thread Pool in java - 122281 views
Implementation of thread Pool in java - 44349 views
Oracle ADF interview Question Part ndash 1 - 40108 views
Serialization Vs Externalization - 36453 viewsAnonymous Classes in Java - 35272 views
What is Ext-Js(Extended JavaScript) - 31741 views
Interview question on thread in Java - 30427 views
Interface vs Abstract Class - 29911 views
Marker interface in java - 29040 views
Hello World Tutorial in ADF - 23440 views
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 67
Tags
ADF ajax ASPNET ASPNET 20 CNET CNET 20 code example column Design Pattern
Example extjs features get hashmap hibernate J2EE Java Java design Pattern Javascript Jetspeed2 Jquery
JSF JSF 20 lifecycle managed bean Memory method Microsoft Mysql Open Portal Open Source
Oracle ADF portal programmatically row Spring sql server table Task flow Techartifact Tips value
view object Web Development XML
Go To Top
Copyright 2009-2012 Techartifactcom
Disclaimer
About
You have tried to
access a web page
which is in
violation of your
internet usage
policy
URL
googleadsgdoublecl
adsclient=ca-
pub-7884501643823
output=htmlamp
h=600amp
slotname=25241005
w=160amp
lmt=1360750991amp
flash=114402amp
url=http3A2F
2Fwwwtechartifac
servlet-
from-servlets-
in-javahtmlamp
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 77
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 47
hellip
EmployeeDAO dao = getServletConfig()
getServletContext()
getAttribute(ldquoEMPLDAOrdquo)
Employee empl = daofindById(requestgetParameter(ldquoE_IDrdquo))
hellip
but i think itrsquos not so cleanhellip
BYE
reply
Leave a Reply
Name ()
Email (will not be published) ()
Website
Web Pag
You have tried to access a web page
which is in violation of your internet
usage policy
URLgoogleadsgdoubleclicknetpagead
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 57
Archives
Top Post
Thread Pool in java - 122281 views
Implementation of thread Pool in java - 44349 views
Oracle ADF interview Question Part ndash 1 - 40108 views
Serialization Vs Externalization - 36453 viewsAnonymous Classes in Java - 35272 views
What is Ext-Js(Extended JavaScript) - 31741 views
Interview question on thread in Java - 30427 views
Interface vs Abstract Class - 29911 views
Marker interface in java - 29040 views
Hello World Tutorial in ADF - 23440 views
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 67
Tags
ADF ajax ASPNET ASPNET 20 CNET CNET 20 code example column Design Pattern
Example extjs features get hashmap hibernate J2EE Java Java design Pattern Javascript Jetspeed2 Jquery
JSF JSF 20 lifecycle managed bean Memory method Microsoft Mysql Open Portal Open Source
Oracle ADF portal programmatically row Spring sql server table Task flow Techartifact Tips value
view object Web Development XML
Go To Top
Copyright 2009-2012 Techartifactcom
Disclaimer
About
You have tried to
access a web page
which is in
violation of your
internet usage
policy
URL
googleadsgdoublecl
adsclient=ca-
pub-7884501643823
output=htmlamp
h=600amp
slotname=25241005
w=160amp
lmt=1360750991amp
flash=114402amp
url=http3A2F
2Fwwwtechartifac
servlet-
from-servlets-
in-javahtmlamp
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 77
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 57
Archives
Top Post
Thread Pool in java - 122281 views
Implementation of thread Pool in java - 44349 views
Oracle ADF interview Question Part ndash 1 - 40108 views
Serialization Vs Externalization - 36453 viewsAnonymous Classes in Java - 35272 views
What is Ext-Js(Extended JavaScript) - 31741 views
Interview question on thread in Java - 30427 views
Interface vs Abstract Class - 29911 views
Marker interface in java - 29040 views
Hello World Tutorial in ADF - 23440 views
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 67
Tags
ADF ajax ASPNET ASPNET 20 CNET CNET 20 code example column Design Pattern
Example extjs features get hashmap hibernate J2EE Java Java design Pattern Javascript Jetspeed2 Jquery
JSF JSF 20 lifecycle managed bean Memory method Microsoft Mysql Open Portal Open Source
Oracle ADF portal programmatically row Spring sql server table Task flow Techartifact Tips value
view object Web Development XML
Go To Top
Copyright 2009-2012 Techartifactcom
Disclaimer
About
You have tried to
access a web page
which is in
violation of your
internet usage
policy
URL
googleadsgdoublecl
adsclient=ca-
pub-7884501643823
output=htmlamp
h=600amp
slotname=25241005
w=160amp
lmt=1360750991amp
flash=114402amp
url=http3A2F
2Fwwwtechartifac
servlet-
from-servlets-
in-javahtmlamp
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 77
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 67
Tags
ADF ajax ASPNET ASPNET 20 CNET CNET 20 code example column Design Pattern
Example extjs features get hashmap hibernate J2EE Java Java design Pattern Javascript Jetspeed2 Jquery
JSF JSF 20 lifecycle managed bean Memory method Microsoft Mysql Open Portal Open Source
Oracle ADF portal programmatically row Spring sql server table Task flow Techartifact Tips value
view object Web Development XML
Go To Top
Copyright 2009-2012 Techartifactcom
Disclaimer
About
You have tried to
access a web page
which is in
violation of your
internet usage
policy
URL
googleadsgdoublecl
adsclient=ca-
pub-7884501643823
output=htmlamp
h=600amp
slotname=25241005
w=160amp
lmt=1360750991amp
flash=114402amp
url=http3A2F
2Fwwwtechartifac
servlet-
from-servlets-
in-javahtmlamp
ing Servlet from Servlets in Java | Techartifact httpwwwtechartifactcomblogs201103calling-servlet-from-servlet
7 13-02-2013 1558
8202019 Calling Servlet From Servlets in Java _ Techartifact
httpslidepdfcomreaderfullcalling-servlet-from-servlets-in-java-techartifact 77
Top Related