Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > questions on J2EE

Reply
Thread Tools

questions on J2EE

 
 
gandhi.pathik@gmail.com
Guest
Posts: n/a
 
      02-09-2007
Hi Friends,

I have few questions please let me know the answers. that would be
very helpful to me.

1). If i create 10 different request from 10 browser windows for the
same servlet, then how we can ensure that same servlet instance is
willing to serve all the requests?

2).What is the difference between valueobject and plain javabean
class?
why valueobject is preferred over javabean class?

3).If i write code like request.getRequestDispatcher("www.yahoo.com/
login.jsp")? would it work or not? what will be the output?

Thanks and Regards,
Pathik S Gandhi

 
Reply With Quote
 
 
 
 
Cool Guy
Guest
Posts: n/a
 
      02-09-2007
Hi Pratik,

Regarding your first questions - print this.toString() in the service
method and then create different requests,It will give the same value
for all request created.

Hope it helps...

- Sudhir

On Feb 9, 2:49 pm, "gandhi.pat...@gmail.com" <gandhi.pat...@gmail.com>
wrote:
> Hi Friends,
>
> I have few questions please let me know the answers. that would be
> very helpful to me.
>
> 1). If i create 10 different request from 10 browser windows for the
> same servlet, then how we can ensure that same servlet instance is
> willing to serve all the requests?
>
> 2).What is the difference between valueobject and plain javabean
> class?
> why valueobject is preferred over javabean class?
>
> 3).If i write code like request.getRequestDispatcher("www.yahoo.com/
> login.jsp")? would it work or not? what will be the output?
>
> Thanks and Regards,
> Pathik S Gandhi



 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      02-09-2007
> Cool Guy wrote:

Please do not top post.

"gandhi.pat...@gmail.com" wrote:
>> 1). If i create 10 different request from 10 browser windows for the
>> same servlet, then how we can ensure that same servlet instance is
>> willing to serve all the requests?


"willing to" - by writing the servlet in a thread-safe manner.

"actually does" - I don't believe you can. Or would want to.

You can write a servlet to implement the SingleThreadModel
<http://java.sun.com/javaee/5/docs/tutorial/doc/Servlets5.html#wp75172>
to force that one instance sequentially serves each request it receives, but
not that there be only one such instance.

From the link:
"A web container can implement this guarantee by synchronizing access to a
single instance of the servlet, or by maintaining a pool of web component
instances and dispatching each new request to a free instance. This interface
does not prevent synchronization problems that result from web components
accessing shared resources such as static class variables or external objects.
In addition, the Servlet 2.4 specification deprecates the SingleThreadModel
interface."

>> 2).What is the difference between valueobject and plain javabean
>> class?


"Value object' is a generic term for any object whose job is to represent a
set of attributes - a "noun" in your object model. A "JavaBean" object is
often a value object, and it follows a set of nomenclature and structural
conventions put forward by the Java API. When a JavaBean is used as a value
object, it is a particular way to implement a value object.

>> why valueobject is preferred over javabean class?


There is no such preference. You can use either, or both at once in the sense
that a JavaBean in this scenario would also be a value object. I write all my
value objects as JavaBeans.

For many projects it is a good practice to separate the value objects
(implemented as JavaBeans or not) from the "process objects" or "behavioral
objects" that use the value objects. Consider EJBs, which can be entity beans
or session beans. (An entity object is a specialization of a value object,
also implementable as a JavaBean.)

>> 3).If i write code like
>> request.getRequestDispatcher("www.yahoo.com/login.jsp")?
>> would it work or not?


That would depend on whether there were a directory "www.yahoo.com/" relative
to the current location within the context root, and a "login.jsp" within it
(assuming that by "work" you mean "return a non-null RequestDispatcher object").

>> what will be the output?


A RequestDispatcher object or null.
<http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getRequestDispatcher(java.lang .String)>
<http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/RequestDispatcher.html>

- Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best JAVA/ J2EE Training Institute in Delhi, Live Projects onJAVA/J2EE, Short term Java courses are also available. Rajive Narain Java 0 09-18-2009 10:48 AM
Shine J2EE Framework 1.2 Vs. J2EE Frameworks mehdi mousavi Java 0 02-15-2009 04:55 PM
j2ee SDK, javax.* and j2ee implementations T.G. Java 1 01-04-2006 08:22 PM
LAMP & J2EE as opposed to LAMP vs J2EE Ross M. Greenberg Java 6 12-24-2004 09:59 PM
Re: Questions....questions....questions Patrick Michael A+ Certification 0 06-16-2004 04:53 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57