dharmendra Rathor

Greenhorn
+ Follow
since Mar 20, 2007
Merit badge: grant badges
For More
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 dharmendra Rathor

If
"<a href="http://www.yahoo.com/" /a>" is a part of html file and we have to retrieve URL (http://www.yahoo.com/) form html page then we can use

tagged regular expression
(<a href=")(http://[a-z,.]*/)(" /a>
and value of tagged expression two ie (\2)will give the desired output.
16 years ago
I have cleared the exam but not received the certificate .
What can i do regarding this?
Inside web.xml file listener element should be declared first then servlet ?
TRUE
FALSE

what is answer ?
3. Consider the following code for the doGet() method:
public void doGet(HttpServletRequest req,
HttpServletResponse res)
{
PrintWriter out = res.getWriter);
out.println("<html><body>Hello</body></html>");
//1--here--
res.sendError(HttpServletResponse.SC_UNAUTHORIZED);

}
Which of the following lines can be inserted at //1 so that the above code does
not throw any exception?
A: res.flushBuffer();
B: res.resetBuffer();
C: res.clearStatus();
D: if ( ! res.isCommitted() )

What is the answer of obove question ?
Page 330 HFSJ Book question 6
What is the correct answer D or E ? (In Book it is E)
4. Which of the following methods will be invoked on a session attribute that
implements appropriate interfaces when the session is invalidated? (Select one)
a sessionDestroyed of HttpSessionListener
b attributeRemoved of HttpSessionAttributeListener
c valueUnbound of HttpSessionBindingListener
d sessionWillPassivate of HttpSessionActivationListener
A Client use two different browser to request the same servlet , will session be same for both request form client .
Which of the following statements are true?
Choose at least one answer.
a. The init method is called each time a Servlet service method runs
b. The init method is called by the container when it is placed into service
c. The init method cannot be overriden because it is marked as final
d. When a container shuts down it will call the undeploy method of running servlets
e. When a container shuts down it will call the destroy method of running servlets

Answer e ,b
Is b correct answer ?
Which of the following statements is true of simple tags
Choose at least one answer.
a. Simple tags cannot perform iteration Incorrect
b. Each time a simple tag iterates the doTag method is invoked
c. The doTag method returns EVALUATE_BODY until the completion of iteration Incorrect
d. Simple tags may not have a body-content type of JSP Correct

What is the answer ?
Given that a servlet is correctly declared with the tag

<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>com.examulator.HelloWorld</servlet-class>
</servlet>


Which of the following represent the correct syntax for mapping a servlet url to a servlet name

a)
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>hello</url-pattern>
</servlet-mapping>

b)
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>*.java</url-pattern>
</servlet-mapping>

c)
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

d)
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/com.examulator.HelloWorld</url-pattern>
</servlet-mapping>

answer is ( c , d )
Why d is also true ?
Given a JSP page called mypage.jsp with the following code

<%
request.setAttribute("greeting","good");
%>
<jsp:include page="menu.jsp" />
<p>morning</p>

And an available file called menu.jsp that contains the following code

<%
String greeting = (String) request.getAttribute("greeting");
out.print(greeting);
%>

What will happen when you attempt to compile and run mypage.jsp?
Choose one answer.
a. Compilation error the jsp:include tag takes a paramter of file not page Incorrect
b. compilation and output of good only Incorrect
c. compilation and output of good morning Correct
d. compilation and output of greeting Incorrect
e. compilation and output of greeting morning Incorrect
f. compilation and output of greeting morning Incorrect
Answer is c .
great monica gracious gracious !!!
[ May 03, 2007: Message edited by: pragmatic dsr ]
17 years ago
May be this will help you
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>

<TITLE> New Document </TITLE>
<script type="text/JavaScript">
function checkString() {
var checkRE = '[\#\"\\\/\']' ;
var inputString = document.forms[0].phone.value
if(inputString.match(checkRE)) {
alert( "String contain special char " );
}
}
</script>
</HEAD>
<BODY>
<form>
Enter string
<input type="text" name="phone" onKey Up="checkString()">
</form>
</BODY>
</HTML>
[ May 03, 2007: Message edited by: pragmatic dsr ]
First thing to know is java uses pass by value methodology for passing argument to method.
S1 is a reference object. When you call [ new MWC205().m1(s1); ] method m1 you are passing reference of s1 by value i.e.
A copy of original reference to s1 is passed to method m1 . Now at this point original reference and a copy reference both are pointing to same
object , so inside method m1 " S1.append("B") " will change the original object and it will hold value "AB" .
On call to method m2 " new MWC205().m2(s1); " a copy of original reference to s1 is passed to m2 . Inside method m2 a new object of same
name s1 is created and displayed as output [ note here this new object s1 has nothing to do with original reference of s1 , this is a complete new
object ] .
At step " new MWC205().m3(s1); " no change is done to reference object s1 , only the value is displayed .
Hence the final value which object s1 is holding is " AB " .
17 years ago