Forums Register Login

some interview questions

+Pie Number of slices to send: Send
1)How much data the session object can store?
2)what can you do in program in order to make browser not to keep your pages in cache?
3) what is action servlet?
4) How to call a method in the EJB from a servlet ?
5) How to get pop-up window while clicking on the button ?
6) which one is best amoung cookies,url rewriting,hidden fields,http seesion ? and why?
7)what is the difference between PrintWriter and jsp writer
[ July 12, 2006: Message edited by: Bear Bibeault ]
+Pie Number of slices to send: Send
What were your answers?
+Pie Number of slices to send: Send
I din't answered....i dont know... thats why i am asking...
Please tell me the answers
+Pie Number of slices to send: Send
 

Originally posted by Durga Krishna:
1)How much data the session object can store?
2)what can you do in program in order to make browser not to keep your pages in cache?
3) what is action servlet?
4) How to call a method in the EJB from a servlet ?
5) How to get pop-up window while clicking on the button ?
6) which one is best amoung cookies,url rewriting,hidden fields,http seesion ? and why?
7)what is the difference between PrintWriter and jsp writer



If you want a good book on the subjects, I recommend Head First Servlets/JSP. Refer to Struts documentation for number 3. Number 4 requires you to get a reference to the EJB Home, and accessing the method via the bean's component interface. Number 5 can be done in Javascript.

For more info, Google is your good friend.
+Pie Number of slices to send: Send
1) How much data the session object can store?
A. There is no limit, but huge data can adversely affect performance.

2) what can you do in program in order to make browser not to keep your pages in cache?

A. You can set some HTTP headers in your servlet or JSP telling browser not to cache the pages.




3) what is action servlet? Read up on STRUTS.

A. Controller (ActionServlet class and Request Processor class): The controller receives the request from the browser, and makes the decision where to send the request based on the struts-config.xml.


4) How to call a method in the EJB from a servlet ? read up on EJBs
A.
1. Make A JNDI Lookup to get the Home interface in your Servlet's init() method.
2. Create the remote interface from your Home stub.
3. invoke your business methods on the remote interface within your doGet() or doPost() method.

5) How to get pop-up window while clicking on the button ?

Using some JavaScript code in Your HTML code.



6) which one is best amoung cookies,url rewriting,hidden fields,http seesion ? and why?

A. HTTP session. Because

-- it is more secured (due to privacy, data are kept on the server and not sent to the prowser. Only session id is sent to the browser).

-- HttpSession mechanisms gives better performance when compared to other mechanims because it stores the session data in memory and reduces overhead on network. Only session id will be passed between client and the server. But it does not scale well when the session data is huge and the concurrent number of users are more because of increase in memory overhead and also increase in overhead on garbage collection.

-- No limit on size of data that can be stored.

7) what is the difference between PrintWriter and jsp writer

A. The JSP abstract class is similar in some of the functionality found in java.io.PrintWriter classes, however it differs in that it throws java.io.IOException from the print methods which PrintWriter does not.The advantage of throwing an exception is that if your HTTP connection is broken for some reason, your JSP won't sit there trying to send characters to a broken connection.

Hope it helps. But as was suggested, learn the fundamentals by reading books/articles.
+Pie Number of slices to send: Send
 

Originally posted by ak pillai:

6) which one is best amoung cookies,url rewriting,hidden fields,http seesion ? and why?

A. HTTP session. Because....



The question only asks "which is best" without saying "what for" or what conditions exist.
The only correct answer for an absurd question like this is "it depends".
All of the things mentioned serve different purposes. In some areas, those purposes may overlap but not enough to make a blanket statement, declaring one is better than the other.

It's like trying to answer the question: "Which is better, a brush, a roller, a pencil, or a spray can?".
+Pie Number of slices to send: Send
You are right Ben.

1. HttpSession
--There is no limit on the size of the session data kept.
--The performance is good.
--This is the preferred way of maintaining state. If we use the HTTP session with the application server�s persistence mechanism (server converts the session object into BLOB type and stores it in the Database) then the performance will be moderate to poor.

Note: When using HttpSession mechanism you need to take care of the following points:

--Remove session explicitly when you no longer require it.
--Set the session timeout value.
--Your application server may serialize session objects after crossing a certain memory limit. This is expensive and affects performance. So decide carefully what you want to store in a session.

2. Hidden fields

-- There is no limit on size of the session data.
-- May expose sensitive or private information to others (So not good for sensitive information).
-- The performance is moderate.

3. URL rewriting
-- There is a limit on the size of the session data.
-- Should not be used for sensitive or private information.
-- The performance is moderate.

4. Cookies
-- There is a limit for cookie size.
-- The browser may turn off cookies.
-- The performance is moderate.

The benefit of the cookies is that state information can be stored regardless of which server the client talks to and even if all servers go down. Also, if required, state information can be retained across sessions.
+Pie Number of slices to send: Send
My point is that you can't answer a question like that without asking more questions. He only asked 'what is better'. He never said, 'what for'.
You made the assumption that this was for simulating a statefull environment and stated the pros and cons of each.

What if the interviewer was talking about a 'remember me' feature that keeps a user from having to log into a site everytime they go to it?

What if they're talking about maintaing state for machines that don't support session cookies?

What if all that is needed is a way to pass a student id through a form without displaying it on the screen?


Suppose you were interviewing someone for a carpenter's position, and you asked him: "what's better, a hammer, a saw, or a screwdriver?".
Would you hire that person if he told you which was better, without inquiring about the actual task at hand? I would hope not.

It was either a stupid question or a trick question designed to see if the interviewee was really paying attention. In either case the question, as it was asked, didn't have a correct answer.



Also cookies (session cookies) and url re-writing are two of the ways that containers distinguish clients in order to maintain an http ession.
This is another reason why it is absurd to ask whether either is better than an http session; They are part of an http session.
Could you hold this puppy for a sec? I need to adjust this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1132 times.
Similar Threads
Servlet
please tell me when to use Session and Cookie?
web-inf vs meta-inf
Different ways of implementing shopping cart
Interview Questions Help
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:28:39.