Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubts in HFSJ

 
Bhavik Patel
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1>
Is there a way to access methods defined in servlet context with EL expressions...
like we do for pageContext.request.method

2>
can we access all methods defined in request object just like we did for pageContext.request.method???Is it possible for other objects like response pageContext.response.anymethod

3>Related to EL Functions --Is it possible to specify return type as any class object for example foo.Dog in methods and is it possible to specify any class object as method arguements...

Thanks..
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bhavik,

1>
Is there a way to access methods defined in servlet context with EL expressions...
like we do for pageContext.request.method

2>
can we access all methods defined in request object just like we did for pageContext.request.method???Is it possible for other objects like response pageContext.response.anymethod

3>Related to EL Functions --Is it possible to specify return type as any class object for example foo.Dog in methods and is it possible to specify any class object as method arguements...


1. It is possible to access method defined in servlet context, using yhe syntax pageContext.servletContext.anyProperty.

2. As the pageContext object provided the getter methods for response, session, servlet context we can access all properties of these objects.

This mechanism though accessing methods indirectly, we can not access any methods in the above objects. We actually accessing the properties of these objects, considerine these objects as Beans, so you can not access the method getAttribute(..) on the request or session object as the method sign. is not as accoring to the Bean specification.

3. It is possible to specify return type as any class object and is it possible to specify any class object as method arguements. You have to specify the full class names of return type and arguments in tld for thses function

<taglib>
��..
<function>
<name>anyName</name>
<function-class>mypkg.MyFunctions</function-class>
<function-signature>mypackage.MyObject nickName(mypackage.MyObject1) </function-signature>
</function>

</taglib>

Thanks
 
Kuppusamy Venkatasubramanian
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Narendar,

Can you answer my question, if your assertion is true.

In the code snippet shown in page 384 of HF, to get the request method,
it has been shown like pageContext.request.method which when called using a JSP shows like GET or POST. If i want to get a servlet initialization parameter from config, i used like pageContext.config.ininParam but the code threw error saying.. there is no property as config in tomcat 5.5.9. Where can i see the property like request in pageContext.request.method. I couldn't find that under javax.servlet.http.jsp. How can i get the init parameter for a jsp using config? Is that container implemented?

Regards,
SAM..
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javax.servlet.jsp.PageContext
This class has a method called "getRequest() " which returns ServletRequest object. Here remove the word get and convert the first letter to lower case which gets you the "request" property.


How can i get the init parameter for a jsp using config? Is that container implemented?
Check out this Link. Listen to what Bear says
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kuppusamy,

You can not get initial parameters using this technique. The getIniitParameter (param) does not fit in this case, because it require some arguments. There is not specified anywhere that which methods are treated as properties.

Acoording to the Javabean spec. the property have getter setter methods in the form

public type1 getXXX() -- WITH NO ARGUMENTS.
public void setXXX(type1)

thats it.

Now Consider the pageContext as bean Object. The PageContext class have methods like getServletContext(), getRequest(), getSession() etc. You can acess these like pageContext.request, pageContext.servletContext etc in EL.

These SevletContext object have some methods like getMajorVersion(), getMinorversion() with no arg. so we can access these methods treating it as properties to sevletContext bean as pageContext.servletContext.majorVersion and pageContext.servletContext.minorVersion.

Hope it help you.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic