|Home |Login |Registration |Struts Step by Step Tutorial |Hibernate Step by Step Tutorial |Spring Step by Step Tutorial |JSP Step by Step Tutorial |JDBC Step by Step Tutorial |Web Services Step by Step Tutorial |EJB fundamentals | ORACLE Step by Step Tutorial | SCJP 5.0 and SCJP 6.0 Study Guide | SCWCD 5.0 Study Guide | SCJP Tips
SCJP mock test | SCJP DUMP | SCWCD mock test |Java online test exam | JSP online test | ORACLE online test | Hibernate online test | Servlet online test | Struts online test | EJB online test | C online test | C++ online test | Aptitude online test

Java interview questions | JSP interview questions | ORACLE interview questions | Hibernate interview questions | Servlet interview questions | Struts interview questions | JDBC interview questions | C/C++ interview questions | Spring interview questions | JMS interview questions | Informatica interview questions | EJB interview questions | OOPS and Design Pattern interview questions
1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc) JobsJobs and Walkins

Tutorial Home
SCJP 6 Simulator Exam Kit
OCAJP 7 Simulator Exam Kit
OCPJP 7 Simulator Exam Kit
SCWCD5.0 Simulator Exam Kit
OCEJWCD 6 Simulator Exam Kit
Struts Tutorial Home
Spring Tutorial Home
Hibernate Tutorial Home
JSP Tutorial Home
JDBC Tutorial Home
Webservices Tutorial Home
EJB Fundamentals

Hibernate

  1. Advantage of Hibernate over JDBC

  2. Hibernate Setup with an web Application

  3. First Hibernate Application

  4. Hibernate mapping with Database TABLE

  5. Hibernate Data Type-Java Data Type - SQL Data Type mapping

  6. One to Many Relation in Hibernate

  7. One to Many Relation in Hibernate bi-directional

  8. Many to Many Relation in Hibernate

  9. HQL: The Hibernate Query Language

  10. Criteria Queries

  11. Criteria Queries : Equal (eq), Not Equal(ne), Less than (le), greater than (gt),greater than or equal(ge) and Ordering the results

  12. Criteria Queries: And OR conditions

  13. Hibernate generator to generate id (primary key)

  14. prevent concurrent update in Hibernate,slate object updatation in Hibernate,version checking in Hibernate

    Struts


  1. Model View Controller (MVC)

  2. Model View Controller (MVC)

  3. Struts Flow-How Struts Works?

  4. Struts Tutorial - Struts Setup- First Struts Action class setup

  5. Message Resources

  6. Validation Framework

  7. Validation Framework-client side

  8. ForwardAction

  9. IncludeAction

  10. DispatchAction

  11. LookupDispatchAction

  12. DynaActionForm

  13. DynaActionForm

  14. Struts Tutorial - Mutli-click prevention using struts tokens-Prevent Duplicate Submission

  15. Logic Iterate Map and List


JSP


  1. JSP Tutorial

  2. Introduction to JSP

  3. JSP Comments

  4. JSP Syntax

  5. JSP Scripting Elements :Scriptlet, expression, declaration

  6. JSP Directives

  7. implicit objects in JSP

  8. JSP Actions

  9. Introduction to JSP

  10. jsp:useBean

  11. The jsp:setProperty Action

  12. The jsp:getProperty Action

  13. Introduction to JSP



Spring



  1. Spring Tutorial

  2. Introduction to Spring

  3. Benefits of Using Spring Framework

  4. Inversion of Control in Spring

  5. Introduction to BeanFactory

  6. Dependency Injection in Spring

  7. Collections Setter Injection

  8. Bean Scopes in Spring

  9. Spring IOC Setup Step by Step

  10. Bean Lifecycle in Spring

  11. ApplicationContext

  12. MessageSources in Spring

  13. Web Spring MVC framework

  14. Developing Your First Spring Web Application

  15. Developing Your Second Spring Web Application with Spring Form

  16. Developing Your First Spring Web Application with Spring Validation Framework with Code Example

  17. Spring integration with Hibernate

SCWCD : HttpServletRequest Interface

SCWCD 1.5 Exam Kit

Using the HttpServletRequest interface, write code to retrieve HTML form parameters from the request, retrieve HTTP request header information, or retrieve cookies from the request.

HTTP Protocol Parameters.

Request parameters for the servlet are the strings sent by the client to a servlet container as part of its request. When the request is an HttpServletRequest object, the container populates the parameters from the URI query string and POST-ed data.

The parameters are stored as a set of name-value pairs. Multiple parameter values CAN exist for any given parameter name. The following methods of the ServletRequest interface are available to access parameters:

  • getParameter

    Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.

    You should only use this method when you are sure the parameter has only ONE value. If the parameter might have MORE than one value, use getParameterValues(String).

    If you use this method with a multivalued parameter, the value returned is equal to the FIRST value in the array returned by getParameterValues.

    If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via getInputStream() or getReader() can interfere with the execution of this method.

  • getParameterNames

    Returns an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an EMPTY Enumeration.

  • getParameterValues

    Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist. If the parameter has a single value, the array has a length of 1.

  • getParameterMap

    Returns an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.

public interface ServletRequest {

	public java.lang.String getParameter(java.lang.String name);
	public java.util.Enumeration getParameterNames();
	public java.lang.String[] getParameterValues(java.lang.String name);
	public java.util.Map getParameterMap();

}
					

The getParameterValues method returns an array of String objects containing all the parameter values associated with a parameter name. The value returned from the getParameter method must be the FIRST value in the array of String objects returned by getParameterValues. The getParameterMap method returns a java.util.Map of the parameter of the request, which contains names as keys and parameter values as map values.

public void doPost(HttpServletRequest request, HttpServletResponse res)
		throws IOException, ServletException {
	Enumeration e = request.getParameterNames();
	PrintWriter out = res.getWriter ();
	while (e.hasMoreElements()) {
		String name = (String)e.nextElement();
		String value = request.getParameter(name);
		out.println(name + " = " + value);
	}
}					

Data from the query string and the post body are aggregated into the request parameter set. Query string data is presented BEFORE post body data. For example, if a request is made with a query string of a=hello and a post body of a=goodbye&a=world, the resulting parameter set would be ordered a=(hello, goodbye, world).

The following are the conditions that must be met before post FORM data will be populated to the parameter set:

  1. The request is an HTTP or HTTPS request.

  2. The HTTP method is POST.

  3. The content type is application/x-www-form-urlencoded.

  4. The servlet has made an initial call of any of the 'getParameter' family of methods on the request object.

If the conditions are not met and the post form data is not included in the parameter set, the post data must still be available to the servlet via the request object's input stream. If the conditions are met, post form data will no longer be available for reading directly from the request object's input stream.

Headers.

A servlet can access the headers of an HTTP request through the following methods of the HttpServletRequest interface:

  • getHeader

    Returns the value of the specified request header as a String. If the request did not include a header of the specified name, this method returns null. If there are multiple headers with the same name, this method returns the first head in the request. The header name is case insensitive. You can use this method with any request header.

  • getHeaders

    Returns all the values of the specified request header as an Enumeration of String objects.

    Some headers, such as Accept-Language can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list. If the request did not include any headers of the specified name, this method returns an EMPTY Enumeration. The header name is case INSENSITIVE. You can use this method with any request header.

  • getHeaderNames

    Returns an enumeration of all the header names this request contains. If the request has no headers, this method returns an empty enumeration.

The getHeader method returns a header given the name of the header. There can be multiple headers with the same name, e.g. Cache-Control headers, in an HTTP request. If there are multiple headers with the same name, the getHeader method returns the first header in the request. The getHeaders method allows access to all the header values associated with a particular header name, returning an Enumeration of String objects.
public interface HttpServletRequest {

	public java.lang.String getHeader(java.lang.String name);
	public java.util.Enumeration getHeaders(java.lang.String name);
	public java.util.Enumeration getHeaderNames();

}
					

Headers may contain String representations of int or Date data. The following convenience methods of the HttpServletRequest interface provide access to header data in a one of these formats:

  • getIntHeader

    Returns the value of the specified request header as an int. If the request does not have a header of the specified name, this method returns -1. If the header cannot be converted to an integer, this method throws a NumberFormatException.

    The header name is case INSENSITIVE.

  • getDateHeader

    Returns the value of the specified request header as a long value that represents a Date object. Use this method with headers that contain dates, such as If-Modified-Since.

    The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive.

    If the request did not have a header of the specified name, this method returns -1. If the header can't be converted to a date, the method throws an IllegalArgumentException.

If the getIntHeader method cannot translate the header value to an int, a NumberFormatException is thrown. If the getDateHeader method cannot translate the header to a Date object, an IllegalArgumentException is thrown.
public interface HttpServletRequest {

	public int getIntHeader(java.lang.String name);
	public long getDateHeader(java.lang.String name);

}
					

public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
	response.setContentType("text/html");
	PrintWriter out = response.getWriter();
	Enumeration e = request.getHeaderNames();
	while (e.hasMoreElements()) {
		String name = (String)e.nextElement();
		String value = request.getHeader(name);
		out.println(name + " = " + value);
	}
}
					

Cookies.

The HttpServletRequest interface provides the getCookies method to obtain an array of cookies that are present in the request. This method returns null if no cookies were sent.

The cookies are data sent from the client to the server on every request that the client makes. Typically, the only information that the client sends back as part of a cookie is the cookie name and the cookie value. Other cookie attributes that can be set when the cookie is sent to the browser, such as comments, are not typically returned. Several cookies might have the same name but different path attributes.

public interface HttpServletRequest {

	public Cookie[] getCookies();

}
					
package javax.servlet.http;

public class Cookie implements java.lang.Cloneable {
	...
	public Cookie(java.lang.String name, java.lang.String value);
	public java.lang.String getName();
	public java.lang.String getPath();
	public java.lang.String getValue();
	...
}
					

SCJP 6 Simulator Exam Kit
OCAJP 7 Simulator Exam Kit
OCPJP 7 Simulator Exam Kit
SCWCD5.0 Simulator Exam Kit
OCEJWCD 6 Simulator Exam Kit

Suggested Jobs

   More Jobs >>
The information you are posting should be related to java and ORACLE technology. Not political. SCJP 5.0 Simulator 642+ Questions With Explanations
SCJP 6.0 Simulator 664+ Questions With Explanations
SCWCD 5.0 Simulator 556+ Questions With Explanations
SCWCD 4.0 Simulator 500+ Questions With Explanations
OCA 10g Simulator 594+ Questions With Explanations
Hiring made easy Harness social networking, employee referrals, Agency portal and Job Portals