shailendra shrivastava

Greenhorn
+ Follow
since Nov 16, 2004
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 shailendra shrivastava

--------------------------------------------------------------------------------
when i try compling the servlet then i get 6 error saying package
javax.servlet does not exists...


package mypackage;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;




public final class Hello extends HttpServlet {



public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {

response.setContentType("text/html");
PrintWriter pw = response.getWriter();

pw.println("<html>");
pw.println("<head>");
pw.println("<title>Sample Application Servlet Page</title>");
pw.println("</head>");
pw.println("<body bgcolor=white>");

pw.println("<table border=\"0\">");
pw.println("<tr>");
pw.println("<td>");
pw.println("<img src=\"images/tomcat.gif\">");
pw.println("</td>");
pw.println("<td>");
pw.println("<h1>Sample Application Servlet</h1>");
pw.println("This is the output of a servlet that is part of");
pw.println("the Hello, World application. It displays the");
pw.println("request headers from the request we are currently");
pw.println("processing.");
pw.println("</td>");
pw.println("</tr>");
pw.println("</table>");

pw.println("<table border=\"0\" width=\"100%\">");
Enumeration names = request.getHeaderNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
pw.println("<tr>");
pw.println(" <th align=\"right\">" + name + ":</th>");
pw.println(" <td>" + request.getHeader(name) + "</td>");
pw.println("</tr>");
}
pw.println("</table>");

pw.println("</body>");
pw.println("</html>");

}


}
18 years ago
when i try compling the servlet then i get 6 error saying package
javax.servlet does not exists...


package mypackage;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;




public final class Hello extends HttpServlet {



public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {

response.setContentType("text/html");
PrintWriter pw = response.getWriter();

pw.println("<html>");
pw.println("<head>");
pw.println("<title>Sample Application Servlet Page</title>");
pw.println("</head>");
pw.println("<body bgcolor=white>");

pw.println("<table border=\"0\">");
pw.println("<tr>");
pw.println("<td>");
pw.println("<img src=\"images/tomcat.gif\">");
pw.println("</td>");
pw.println("<td>");
pw.println("<h1>Sample Application Servlet</h1>");
pw.println("This is the output of a servlet that is part of");
pw.println("the Hello, World application. It displays the");
pw.println("request headers from the request we are currently");
pw.println("processing.");
pw.println("</td>");
pw.println("</tr>");
pw.println("</table>");

pw.println("<table border=\"0\" width=\"100%\">");
Enumeration names = request.getHeaderNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
pw.println("<tr>");
pw.println(" <th align=\"right\">" + name + ":</th>");
pw.println(" <td>" + request.getHeader(name) + "</td>");
pw.println("</tr>");
}
pw.println("</table>");

pw.println("</body>");
pw.println("</html>");

}


}
18 years ago
JSP
hiiiii !
' i m shailendra shrivastava ... well i whould like to know is there any standard available which gives a information on the performance and working of (jsp/servlets ) and swings ...



means camparision between the working with (jsp/servlets) and swings
[jsp/servlets ] together.
19 years ago
JSP
PAPER :
__1_________________________________________________________________
In the init(ServletConfig) method of Servlet life cycle, what method can be used to access the ServletConfig object ?
(a) getServletInfo()
(b) getInitParameters()
(c) getServletConfig()
ANS: ()

___________________________________________________________________
2......The Page directive in JSP is defined as follows:
<%@ page language="java" session="false" isErrorPage="false" %>
Then which of the implicit objects won't be available ?
(a) session, request
(b) exception, request
(c) exception, config
(d) session, exception
ANS: I think answer is (d)
___________________________________________________________________
3..
ejbCreate() method of CMP bean returns
(a) null
(b) Primary Key class
(c) Home Object
(d) Remote Object
ANS: (a)
Explanation: ejbCreate() method of BMP bean returns the Primary Key, where as ejbCreate() method of CMP bean returns null.
___________________________________________________________________
4...
How can a EJB pass it's reference to another EJB ?
___________________________________________________________________
5....Which of the following is correct syntax for an Abstract class ?
(a) abstract double area() { }
(b) abstract double area()
(c) abstract double area();
(d) abstract double area(); { }
ANS: (c)
___________________________________________________________________
6...........
A JSP page is opened in a particular Session. A button is present in that JSP page onclick of which a new Window gets opened.
(a) The Session is not valid in the new Window
(b) The Session is valid in the new Window
ANS: I think the answer is (b)
___________________________________________________________________
7....
Which of the following JSP expressions are valid ?
(a) <%= "Sorry"+"for the"+"break" %>
(b) <%= "Sorry"+"for the"+"break"; %>
(c) <%= "Sorry" %>
(d) <%= "Sorry"; %>
ANS:
___________________________________________________________________
8....
A class can be converted to a thread by implementing the interface __________
(a) Thread
(b) Runnable
ANS: (b)
___________________________________________________________________
9...
What is the output of following block of program ?
boolean var = false;
if(var = true) {
System.out.println("TRUE");
} else {
System.out.println("FALSE");
}

(a) TRUE
(b) FALSE
(c) Compilation Error
(d) Run-time Error
ANS: ()
EXPLANATION: The code compiles and runs fine and the 'if' test succeeds because 'var' is set to 'true' (rather than tested for 'true') in the 'if' argument.
___________________________________________________________________
10...Which is not allowed in EJB programming ?
(a) Thread Management
(b) Transient Fields
(c) Listening on a Socket
ANS:
___________________________________________________________________
11.What happens if Database Updation code is written in ejbPassivate() method and if this method is called ?
(a) Exception is thrown
(b) Successfully executes the Database Updation code
(c) Compilation error occurs indicating that Database Updation code should not be written in ejbPassivate()
(d) ejbStore() method is called
ANS:
___________________________________________________________________
12...A Vector is declared as follows. What happens if the code tried to add 6 th element to this Vector
new vector(5,10)
(a) The element will be successfully added
(b) ArrayIndexOutOfBounds Exception
(c) The Vector allocates space to accommodate up to 15 elements
ANS: (a) and (c)
EXPLANATION: The 1 st argument in the constructor is the initial size of Vector and the 2 nd argument in the constructor is the growth in size (for each allocation)
This Vector is created with 5 elements and when an extra element (6 th one) is tried to be added, the vector grows in size by 10.
___________________________________________________________________
13...Which is the data structure used to store sorted map elements ?
(a) HashSet
(b) Hashmap
(c) Map
(d) TreeMap
ANS: I think the answer is (d)
___________________________________________________________________
14.SessionListerner defines following methods
(a) sessionCreated, sessionReplaced
(b) sessionCreated, sessionDestroyed
(c) sessionDestroyed, sessionReplaced
ANS:
___________________________________________________________________
15...Which of the following is true ?
(a) Stateless session beans doesn't preserve any state across method calls
(b) Stateful session beans can be accesses by multiple users at the same time
ANS: (a)
___________________________________________________________________
16..Stateful Session beans contain
(a) Home Interface
(b) Remote Interface
(c) Bean Class
(d) All
ANS: (d)
___________________________________________________________________
17..What is the Life Cycle of Session bean ?
___________________________________________________________________
18..Stateless session bean is instantiated by
(a) newInstance()
(b) create()
ANS:
___________________________________________________________________
19.A servlet implements Single Thread model
public class BasicServlet extends HttpServlet implements SingleThreadModel {

int number = 0;
public void service(HttpServletRequest req, HttpServletResponse res) {
}
}
Which is thread safe ?
(a) Only the variable num
(b) Only the HttpServletRequest object req
(c) Both the variable num & the HttpServletRequest object req
___________________________________________________________________
20...If you are trying to call an EJB that is timed out, what will happen ?
(a) Exception
(b) It gets executed
___________________________________________________________________
21..A method is defined in a class as :
void processUser(int i) { }
If this method is overriden in a sub class,_____
(a) the new method should return int
(b) the new method can return any type of values
(c) the argument list of new method should exactly match that of overriden method
(d) the return type of new method should exactly match that of overriden method
ANS: (c) & (d)
___________________________________________________________________
22...In a JSP page, a statement is declared as follows:
<%! String strTemp = request.getParameter("Name"); %>
And below that, an _expression appears as:
<% System.out.println("The Name of person is: "+strTemp); %>
What is the output of this _expression, if this JSP page is invoked in browser using URL : http://localhost:8080/JSP/TrialPage.jsp?Name=Chetana
(Assume that this URL is correct)
(a) The Name of person is: Chetana
(b) The Name of person is:
(c) The Name of person is: null
(d) None
ANS: (a)
___________________________________________________________________
23...Without the use of Cartesian product, how many joining conditions are required to join 4 tables ?
(a) 1
(b) 2
(c) 3
(d) 4
ANS:
___________________________________________________________________
24...What is the output of following piece of code ?
int x = 2;
switch (x) {
case 1:System.out.println("1");
case 2:
case 3:System.out.println("3");
case 4:
case 5:System.out.println("5");
}
(a) No output
(b) 3 and 5
(c) 1, 3 and 5
(d) 3
ANS: ()
19 years ago
PAPER :
___________________________________________________________________
In the init(ServletConfig) method of Servlet life cycle, what method can be used to access the ServletConfig object ?
(a) getServletInfo()
(b) getInitParameters()
(c) getServletConfig()
ANS: (c)
___________________________________________________________________
The Page directive in JSP is defined as follows:
<%@ page language="java" session="false" isErrorPage="false" %>
Then which of the implicit objects won't be available ?
(a) session, request
(b) exception, request
(c) exception, config
(d) session, exception
ANS: I think answer is (d)
___________________________________________________________________
ejbCreate() method of CMP bean returns
(a) null
(b) Primary Key class
(c) Home Object
(d) Remote Object
ANS: (a)
Explanation: ejbCreate() method of BMP bean returns the Primary Key, where as ejbCreate() method of CMP bean returns null.
___________________________________________________________________
How can a EJB pass it's reference to another EJB ?
___________________________________________________________________
Which of the following is correct syntax for an Abstract class ?
(a) abstract double area() { }
(b) abstract double area()
(c) abstract double area();
(d) abstract double area(); { }
ANS: (c)
___________________________________________________________________
A JSP page is opened in a particular Session. A button is present in that JSP page onclick of which a new Window gets opened.
(a) The Session is not valid in the new Window
(b) The Session is valid in the new Window
ANS: I think the answer is (b)
___________________________________________________________________
Which of the following JSP expressions are valid ?
(a) <%= "Sorry"+"for the"+"break" %>
(b) <%= "Sorry"+"for the"+"break"; %>
(c) <%= "Sorry" %>
(d) <%= "Sorry"; %>
ANS:
___________________________________________________________________
A class can be converted to a thread by implementing the interface __________
(a) Thread
(b) Runnable
ANS: (b)
___________________________________________________________________
What is the output of following block of program ?
boolean var = false;
if(var = true) {
System.out.println("TRUE");
} else {
System.out.println("FALSE");
}

(a) TRUE
(b) FALSE
(c) Compilation Error
(d) Run-time Error
ANS: (a)
EXPLANATION: The code compiles and runs fine and the 'if' test succeeds because 'var' is set to 'true' (rather than tested for 'true') in the 'if' argument.
___________________________________________________________________
Which is not allowed in EJB programming ?
(a) Thread Management
(b) Transient Fields
(c) Listening on a Socket
ANS:
___________________________________________________________________
What happens if Database Updation code is written in ejbPassivate() method and if this method is called ?
(a) Exception is thrown
(b) Successfully executes the Database Updation code
(c) Compilation error occurs indicating that Database Updation code should not be written in ejbPassivate()
(d) ejbStore() method is called
ANS:
___________________________________________________________________
A Vector is declared as follows. What happens if the code tried to add 6 th element to this Vector
new vector(5,10)
(a) The element will be successfully added
(b) ArrayIndexOutOfBounds Exception
(c) The Vector allocates space to accommodate up to 15 elements
ANS: (a) and (c)
EXPLANATION: The 1 st argument in the constructor is the initial size of Vector and the 2 nd argument in the constructor is the growth in size (for each allocation)
This Vector is created with 5 elements and when an extra element (6 th one) is tried to be added, the vector grows in size by 10.
___________________________________________________________________
Which is the data structure used to store sorted map elements ?
(a) HashSet
(b) Hashmap
(c) Map
(d) TreeMap
ANS: I think the answer is (d)
___________________________________________________________________
SessionListerner defines following methods
(a) sessionCreated, sessionReplaced
(b) sessionCreated, sessionDestroyed
(c) sessionDestroyed, sessionReplaced
ANS:
___________________________________________________________________
Which of the following is true ?
(a) Stateless session beans doesn't preserve any state across method calls
(b) Stateful session beans can be accesses by multiple users at the same time
ANS: (a)
___________________________________________________________________
Stateful Session beans contain
(a) Home Interface
(b) Remote Interface
(c) Bean Class
(d) All
ANS: (d)
___________________________________________________________________
What is the Life Cycle of Session bean ?
___________________________________________________________________
Stateless session bean is instantiated by
(a) newInstance()
(b) create()
ANS:
___________________________________________________________________
A servlet implements Single Thread model
public class BasicServlet extends HttpServlet implements SingleThreadModel {

int number = 0;
public void service(HttpServletRequest req, HttpServletResponse res) {
}
}
Which is thread safe ?
(a) Only the variable num
(b) Only the HttpServletRequest object req
(c) Both the variable num & the HttpServletRequest object req
___________________________________________________________________
If you are trying to call an EJB that is timed out, what will happen ?
(a) Exception
(b) It gets executed
___________________________________________________________________
A method is defined in a class as :
void processUser(int i) { }
If this method is overriden in a sub class,_____
(a) the new method should return int
(b) the new method can return any type of values
(c) the argument list of new method should exactly match that of overriden method
(d) the return type of new method should exactly match that of overriden method
ANS: (c) & (d)
___________________________________________________________________
In a JSP page, a statement is declared as follows:
<%! String strTemp = request.getParameter("Name"); %>
And below that, an _expression appears as:
<% System.out.println("The Name of person is: "+strTemp); %>
What is the output of this _expression, if this JSP page is invoked in browser using URL : http://localhost:8080/JSP/TrialPage.jsp?Name=Chetana
(Assume that this URL is correct)
(a) The Name of person is: Chetana
(b) The Name of person is:
(c) The Name of person is: null
(d) None
ANS: (a)
___________________________________________________________________
Without the use of Cartesian product, how many joining conditions are required to join 4 tables ?
(a) 1
(b) 2
(c) 3
(d) 4
ANS:
___________________________________________________________________
What is the output of following piece of code ?
int x = 2;
switch (x) {
case 1:System.out.println("1");
case 2:
case 3:System.out.println("3");
case 4:
case 5:System.out.println("5");
}
(a) No output
(b) 3 and 5
(c) 1, 3 and 5
(d) 3
ANS: (b)
___________________________________________________________________
19 years ago