amol re

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

Recent posts by amol re

Assuming the rest of the code is valid,
which is true about this code?
public class TestTag extends TagSupport{
public int doStartTag(){
JspWriter out=pageContext.getOut();
catch(IOException ioex){}
I answered B, because I thought since EVAL_BODY_BUFFERED is not a valid return type, it would throw some run time exception.
Correct answer:
Will not compile. EVAL_BODY_BUFFERED is not a valid return type for a tag that extends TagSupport. EVAL_BODY_INCLUDE or SKIP_BODY would be ok.
How can it check @ compile time???
If my webapp is distributable, is it mandatory to implement the HttpSessionActivationListener?
Select false options related with the directory structure of a web application.
A Servlet class files are kept in yourWepApp/WEB-INF/lib
B JavaBeans are kept in yourWepApp/WEB-INF/classes
C Server.xml is kept in yourWepApp/WEB-INF/
D Images are kept in yourWepApp/images
Answer and explaination:
A, C and D are correct. B is the only true option and therefore incorrect. Jarred classes are kept in /WEB-INF/lib,web.xml (NOT server.xml) is in yourWepApp/WEB-INF/, images CAN be in a folder called images but they do not have to.
I think the correct answer should only be A.
Because the web app doesnt become corrupt if i put a file called server.xml in WEB-INF nor does it stop me from putting images in web-inf/images folder.
Does the exam include questions like these? looks more like "english statement interpretation" question than a web app related question.
probably he's doing it programmatically!
20 years ago
In your including jsp, put the following code or its equivalent:

You should see the time in miliseconds, it takes to include jsp2.
Under normal circumstances, this time difference can vary significantly for each request.IMO, this is because, since the difference is a few miliseconds, it doesnt take much for it to double, triple, depending on the cpu conditions at that particular instant when your page is being included.
20 years ago
You can use
20 years ago
Can you do somethng like this?
When you get the request for that page, check for particular variable in the session. If not set, set it and send the response normally.
If its set, it means, its not the first request for that page in that particular user session. So, show your "cannot resubmit" message.
20 years ago
forward action in your JSP is converted into a RequestDispatcher.forward() in the translated servlet.
sendRedirect and RequestDispatcher.forward() are different in the following ways:
  • Send redirect sends the response to the client with redirect header(i dont know the exact name) which has information about which url to resend request to, to get the actual response. So it involves a round trip. client request->send redicret response->client resends request->response.
  • Forward, on the other hand, handles the forwarding of the request entirely on the server side. The client doesnt even come to know that the reponse was generated by some resource other than the one it had asked the response from.
  • So, the URL in the browser's address bar changes in case of sendRedirect but doesnt change in case of forward.
  • Since sendRedirect forces the client to send a new request to the specified url, you cannot share request scope attributes between servlets if you are using sendRedirect. In case of foward, the request object remains the same which allows u to set some attributes in the request before forwarding it and retrieve them in the forwarded servlet/jsp.

  • 20 years ago
    I dont know the details, but I think sometimes its impossible to see the standard output. I remember facing this problem and not getting a solution.
    Has it got something to do with javaw/java?
    Even I would like to get some clarification on the issue.
    I was trying for the last few days on sun site but even I wasnt able to.
    So finally today googled for the stuff.
    A dozen Servlet spec locations
    JSP Spec
    Is there a separate just java.nio download available??
    I wouldnt take the risk because maybe some classes in java.nio are dependent on some jdk1.4 implementation of some other J2SE package.
    ...Unless Sun promises that its safe to download and use it with jdk1.3...
    20 years ago
    You may wish to go through this concise introductory article which takes just the same problem as an example application.
    20 years ago
    From my personal experience, if you are required to do some acrobatics like these, more often than not, its a hidden case to improve the design. of the approaches could be...

    Finally, I tried using a scriplet which defines an if-statement to conditionally declare the useBean tag with the appropriate class attribute.

    Go one step further and instead of using the useBean tag, instantiate and appropriate class and put it in the appropriate scope.

    and in your page, use

    Btw, how are you making sure that at run time, get property with property name exclusive to derived will not be called if you have an instance of base?
    Your problem at compile time can be solved...but you will have to take care of the run time scenarios...I would suggest relook basic desgin of the application. Maybe the use case that your are trying to realise right now wasnt considered at design time. Maybe a little tweaking somewhere inside the core will eliminate the need for you to do the acrobatics you are required to do right now. or maybe not. just wondering...
    20 years ago

    Thats because there is a slight difference between how the two includes work.
    The include directive, ie. <%@ include file="..." %> is used at translation time. [When the translator generates servlet code from your jsp file]
    At translation time, above directive is replaced by the contents of the file that you specify in the file attribute.
    So, in your included file, if you are referring to a variable declared in the including file, it works because while compiling, the including and included file are part of the same servlet.
    The inlude action, i.e. <jsp:include page="..." /> comes into action at request time.
    So when you are using include action, the above line isnt replaced with the contents of the included page as in case1. Instead, it is replaced by requestDispatcher.include() call.
    Two servlets are formed. One for the including page and the other for the included page.
    At run time, when a request comes to first page which contains the <jsp:include.../>, internally, the container sends a request to the second page. the output of this second page replaces the <jsp:include...> tag that you write.
    In this case if you notice, since there are two different servlets, variables declared in one will not be available in the second.
    Hence the error that you are getting.
    In a nutshell...

    Include directive is
  • Includion of the page contents.
  • Happens at translation time.

  • Include action is
  • Inclusion of the output of the page.
  • Happens at request time.

  • Repercurssions:
    If you use directive:
  • Code in page 2 can use all the varilables and methods from page 1 because eventually both the pages are compiled into single servlet.
  • Slightly improved performance compared to action since there is no request time calling of requestdispatcher.include()
  • If your page 2 is going to change frequently, you yourself will have to take care of translate & compile page 1. Unless you do that, the changes in page2 wont be reflected in page1

  • If you use include action:
  • You are loosely coupling the two pages which arent dependent on each others variables.
  • Useful when you know your page 2 is going to change frequently.You dont have to worry about explicitly compiling page 1. It is not required.
  • You may face standard "Buffering issues".

  • 20 years ago
    While browsing, I observed that this forum has got very few technical topics compared to the many non technical topics.
    Which is unlike the typical javaranch technical forum that i like.. (SCJP, Advanced Java are the ones i frequently browse)
    Does this mean that the SCWCD exam is a little too easy to crack and score??
    just wondering