Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Michael Santosa

Greenhorn
+ Follow
since Mar 13, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Michael Santosa

Hi ranchers...
I am just learning UML and I still confuse about
Class Diagram.. maybe it sounds easy for some
experts in this room discussion.. but it's not
for me.
I am confused about associations..
well let's say there are 2 classes, 1st
is Order and 2nd is Customer...
Of course Customer can have many Orders..
Order 0.. * ----- 1 Customer
(is it right ?)
The problem is how to implement associations
into the class relationship in the java codes ?
Does class Customer have order inside
for example like this ?
class Customer
{
List order; // List of order
}
or it's not neccessary that Class customer
must have instance of class order inside ?
and can be implemented by another class
for example Transactions class that use
both Customer and Order ?
Please light me up ... is there any tutorial
about UML by example associated with
Java codes ?
Thanks for the help ...
[ August 26, 2002: Message edited by: Michael Santosa ]
Is there any ? or is it from Sun Press ??
Given a tag handler defined with <bodycontent>JSP</bodycontent> which implements TagSupport and ONLY overrides doAfterBody with the following lines:
public int doAfterBody() throws JspException {
try { pageContext.getOut().print(� how are you? �);}catch(IOException e) {}
return SKIP_BODY;
}
What will be the result of a jsp with the following part?
<prefix:sufix>
<i>Hello</i>
</prefix:sufix>
1) The jsp page will print: Hello
2) The jsp page will print: Hello how are you?
3) The jsp page will print: how are you? Hello
4) The jsp won't print anything.
The answer is :
4) The jsp won't print anything.
TagSupport.doStartTag by default returns SKIP_BODY and as it is not overriden the body is ignored.
As I remembered that TagSupport doesn't
have doAfterBody, we have to implement
BodyTagSupport... please correct me if
I am wrong.
And what is the different between
JSP 1.1 & JSP 1.2 ?
It seems like I studied JSP 1.1 a lot,
and there are some big different..
Thx..
Hi..
I see that Deployment Descriptor for JSP 1.2 and JSP 1.1 is different. for example :
tlib-version and tlibversion.
jsp-version and jspversion.
So in the real exam we have to follow JSP 1.2 ?
How about if there is a question like this :
Which one is the valid sub-element of
tlib element ?
1. tlib-version
2. tlibversion
3. name
4. info
What will we answer, tlib-version, or
both (tlib-version & tlibversion) ??
Thank you
Thank you Peter..
Now I am not worry about that anymore
I am a bit confused about the Body Content,
here is the piece of codes :
int doAfterTag() throws JspTagException
{
BodyContent bc = getBodyContent();
bc.getEnclosingWriter().println("Test 123");
pageContext.getOut().print("Test 123");
...
So my question is what is the different
between :
bc.getEnclosingWriter().println("Test 123");
and
pageContext.getOut().print("Test 123");
?
And I test that :
bc.getEnclosingWriter().println("Test 123");
Only prints the data out dan doesn't change
the body.
The second question is :
What is the uses of :
out = pageContext.pushBody();
out = pageContext.popBody();
??
(I saw it on generated Servlet).
Does pushBody put the content of the body
into stack, and popBody get the body
again from the Stack ?
Thank you for the help.. I really appreciate it
[ April 26, 2002: Message edited by: Michael Santosa ]
I would like to know if tld files should be located in :
web_app\WEB-INF\tld
is it a rule or we can put it into another
directory ?
Thanks
[ April 26, 2002: Message edited by: Michael Santosa ]
Hi ...
How about if JavaRanch's Mock Exam compared
to the real Exam, which one is more difficult ?
I've taken this Mock exam many times, and get score about 85 to 92, so am I ready for the
real test ?
Thank you
1. <%= "<//%Joe said %\\>" %>
Will be :
<//%Joe said %\> in generated HTML
And remember \\ = \ as in Normal Java.
And <//%Joe said %\> can't be interpreted by
browser so it will display empty
2.
<%= "<\\%Joe said %\\>" %>
Because the same problem \\ = \
Will be :
<\%Joe said %\> in generated HTML
And fortunaly browser is able to interprete
this.. doesn anybody know what is the reason ??
3.
<%= "<\%Joe said" %>
Peter had answered that clearly.
By my question is :
Can we make :
<%= "<% a=a+1; %>" %>
I mean scriptlet in expression ??
When I put this line at my JSP page :
<jsp:useBean id="school" scope="application" class="translator.MyTranslator"/>
Then it will compile it into servlet like this
using TOMCAT :
translator.MyTranslator school = null;
boolean _jspx_specialschool = false;
synchronized (application)
{
school= (translator.MyTranslator)
pageContext.getAttribute("school",PageContext.APPLICATION_SCOPE);
if ( school == null )
{
_jspx_specialschool = true;
try
{
school = (translator.MyTranslator) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "translator.MyTranslator");
}
catch (ClassNotFoundException exc)
{
throw new InstantiationException (exc.getMessage());
}
catch (Exception exc)
{
throw new ServletException (" Cannot create bean of class "+"translator.MyTranslator", exc);
}
pageContext.setAttribute("school", school, PageContext.APPLICATION_SCOPE);
}
}
It means the school bean is always act
as "local variable".. whatever its scope
is.
So when I want to use this instance of
bean again in another JSP page,
then I put the same code
<jsp:useBean id="school" scope="application" class="translator.MyTranslator"/>
Then I will get the same instance, right ?
Please correct me if I am wrong...
Hi Ranchers..
What is the different between Facade & Business
Delegate Pattern & Data Access Object ?
They look the similiar.
They add a layer in the middle,
and to encapsulate sub-system to make it
easier to use and protect client-app of
changes in sub-system.
In My opinion the different is DAO for Data Access purpose, and Business Delegate is for Bussiness logic purpose. And Facade is
for General Purpose.
So it means DAO & Business delegate are
subset from Facade ?
So DAO & Business delegate = Facade ??
Please give me a light about this problem
Thank you...
Thanks for the reply. It seems I have to memorize a lot of things again... :*
Dear Ranchers,
The DTD of web-resource-collection is :
(web-resource-name, description?, url-pattern*,
http-method*)
I have an example :
<web-resource-collection>
<web-resource-name>Name</web-resource-name>
<url-pattern>/servlet/*</url-pattern>
<description>No Description</description>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
Unfortunaly, this sample doesn't work with
Tomcat 4.0..
but this is working fine :
<web-resource-collection>
<web-resource-name>Name</web-resource-name>
<description>No Description</description>
<url-pattern>/servlet/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
The different is only the location of description
tag, that must be written after (web-resource-name).
So it means that we have to be carefull about
the location of each tag ??
Thank you..
In my opinion "object" instance here "is not
really thread safe"..
The codes are :
HttpSession hs = request.getSession();
Object object = hs.getAttribute(attName);
the object itself is thread safe, since
it's a local variable. But the
value referenced by it, is not thread
safe, isn't ? please correct me if I am wrong.
Lets see this example :
In Servlet A
Vector x = new Vector();
x.add("Test");
HttpSession mysession = request.getSession(true);
mysession.setAttribute("test", x);
Now x is put in the session attribute..
And there is another servlet that get it,
and clear the content of vector.
In Servlet B
HttpSession mysession = request.getSession(true);
Vector temp = (Vector) mysession.getAttribute("test");
temp.clear();
And let's back to the servlet A, there is a
command like this :
x.get(1); .. it whould be in dangerous or ??
It depends on servlet implementation,
is setAttribute method of HttpSession save
the Object by reference or it copys the
value ??
So if there is a question about it, for
example is object thread safe ?
Then what would you answer ?
[ April 04, 2002: Message edited by: Michael Santosa ]