Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Marcus Green question  RSS feed

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
State whether the following are True/False (Marcus Green):-


a) <%@taglib tagdir="WEB_INF/tags/taglib.tld" prefix="h" %> is a correct taglib declaration in a jsp.

b) A redirect cannot be performed after anything has been written to the outputstream

c)User & role configuration is not part of servlet/jsp spec


According to me :-

a)
I tried a) . It works but I cannot understand why . tagdir should take a directory but here a filename is specified.


b)
In a servlet if we just have it works :-

response.getWriter().write("Hello Demello");
response.sendRedirect(".....");

We are writing to the outputstream before redirecting.So should not b) be false ??
Only when we say response.flushBuffer() before response.sendRedirect("....."); is called an
exception is thrown.


c) We can define User & role configuration in the container(for eg. in tomcat ) .Then how come
its false
 
Creator of Enthuware JWS+ V6
Bartender
Posts: 3123
259
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Simran,

I tried a) . It works but I cannot understand why . tagdir should take a directory but here a filename is specified.


You can point directly to the tld file according to the jsp2.0 spec:

JSP.7.3.6.3 Usage Considerations
Finally, the fallback rule allows a taglib directive to refer directly to the TLD.
This arrangement is very convenient for quick development at the expense of less
flexibility and accountability. For example, in the case above, it enables:
<%@ taglib uri="/WEB-INF/tlds/PRlibrary_1_4.tld" prefix="x" %>


That <%@taglib tagdir="WEB_INF/tags/taglib.tld" prefix="h" %> works is for me a miracle. Tagdir is used to point to a directory containing tagfiles (ending on .tag) and not for .tld files. This is not defined in the JSP2.0 spec so just consider it container specific.

We are writing to the outputstream before redirecting.So should not b) be false ??


Yes, you are right (unless there is no buffer defined in the servlet-container)

SRV.5.1 Buffering
A servlet container is allowed, but not required, to buffer output going to the client
for efficiency purposes. Typically servers that do buffering make it the default


c)User & role configuration is not part of servlet/jsp spec


The user to role configuration is not defined in the specs, so every container uses its own config-file for that (e.g. tomcat uses tomcat-users.xml)

Regards,
Frits
 
Simran Dass
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

According to Marcus Green -

a is TRUE

b is also TRUE.


But I think a and b both should be false.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender
Posts: 3123
259
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

According to Marcus Green -

a is TRUE
b is also TRUE.
But I think a and b both should be false.


A) it should be false, because nothing is written about it in the specs. The fact that tomcat allows it is questionable.

B) it should be false, and this you can actually find back in the specs:

SRV.5.3 Convenience Methods
The following convenience methods exist in the HttpServletResponse interface:
sendRedirect
sendError
....
If data has been written to the response buffer, but not returned to the client
(i.e. the response is not committed), the data in the response buffer must be
cleared and replaced with the data set by these methods


Regards,
Frits
 
Simran Dass
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks a lot Frits.

I have to give the exam in the next few days so I think I am getting nervous.
Even after I read something in the specs I want to confirm that I am not misunderstanding
anything . Thanks once again.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!