JSP goes through a JSP compiler which will convert the JSP page into a servlet, autogenerating the java code.

The JSP directives instructs the JSP compiler where to put what. Everything that is inside <% %> (called JSP scriptlets) will be put inside the service() method of the generated servlet. Everything inside <%! %> (called JSP declarations) will become part of the actual class of the generated servlet, so your getVal() will become an instance method.

The standard request (and session and pageContext etc) object instances are defined inside the service() method so they are, in effect, ONLY available inside JSP scriptlet sections.

If you are running on Tomcat, for instance, you can look at the actual generated Java code for your JSP pages if you look inside the "work" directory in the Tomcat installation. Might be interesting, if not get a better picture about what is happening "under the hood".

Answer from pap on Stack Overflow
🌐
W3Schools
w3schools.in › jsp › request
JSP Request
This JSP request gets request information like a parameter, remote address, header information, server port, server name, character encoding, content type, etc. A request object is an implicit object that is used to request an implicit object, which is to receive data on a JSP page, which has ...
Discussions

how to use "request" object within a function in jsp - Stack Overflow
If you are running on Tomcat, for ... for your JSP pages if you look inside the "work" directory in the Tomcat installation. Might be interesting, if not get a better picture about what is happening "under the hood". ... Sign up to request clarification or add additional context in comments. ... request is accessible ... More on stackoverflow.com
🌐 stackoverflow.com
Request object in JSP EL
Oracle REST Data Services (ORDS) is the HTTPS Web Gateway for your Oracle Database. Features include SQL Developer Web, Oracle APEX access, REST APIs for your data and databases, Oracle Database API for MongoDB, and much more · Develop REST APIs, PL/SQL, MLE JavaScript, JSON, run SQL and scripts, ... More on forums.oracle.com
🌐 forums.oracle.com
object into string using jsp - Programming & Development - Spiceworks Community
hi I have retrived the data from db in servlet and stored the data in list of beanclass. In servlet ,using setattribute()–set the values In Jsp , Using getattribute() – get the values in jsp my problem is it prints the values in object format Output :[BeanClass@1fc6e42, BeanClass@1fc6e42, ... More on community.spiceworks.com
🌐 community.spiceworks.com
0
November 26, 2009
JSP request object methods
Go to the Jakarta EE Platform javadocs , scroll down the top-left window to jakarta.servlet.http jakarta.servlet.jsp Click jakarta.servlet.http, and you will see HttpServletRequest HttpServletResponse Click HttpServletRequest and you will see all of it's methods on the right. More on reddit.com
🌐 r/javahelp
6
2
January 5, 2022
🌐
TutorialsPoint
tutorialspoint.com › jsp › jsp_client_request.htm
JSP - Client Request
The request object provides methods to get HTTP header information including form data, cookies, HTTP methods, etc. Following table lists out the important methods that can be used to read HTTP header in your JSP program.
🌐
GeeksforGeeks
geeksforgeeks.org › java › jsp-implicit-objects-request-and-response
JSP Implicit Objects - request and response - GeeksforGeeks
Implicit objects are pre-defined ... declaration, simplifying development. ... The request implicit object is an instance of HttpServletRequest....
Published   2 weeks ago
🌐
javakeypoint
javakeypoint.wordpress.com › 2016 › 04 › 03 › jsp-request-object
JSP request Object | javakeypoint
April 4, 2016 - JSP request Object JSP request implicit object is instance of javax.servlet.http.HttpServletRequest . it’s one of the argument of JSP service method. jsp request object is created by the web container We can use request object to get the request ...
🌐
Coderanch
coderanch.com › t › 287083 › java › request-object
getting value from request object (JSP forum at Coderanch)
April 26, 2005 - Here. Put this hideous JSP on your machine and run it. It should be enough to get you going. You don't need to unescape the querystring. getParameter does that for you. For the record, I agree with Bear, if you're going to do scripting in a JSP, take the time to install JSTL.
Find elsewhere
Top answer
1 of 2
23

JSP goes through a JSP compiler which will convert the JSP page into a servlet, autogenerating the java code.

The JSP directives instructs the JSP compiler where to put what. Everything that is inside <% %> (called JSP scriptlets) will be put inside the service() method of the generated servlet. Everything inside <%! %> (called JSP declarations) will become part of the actual class of the generated servlet, so your getVal() will become an instance method.

The standard request (and session and pageContext etc) object instances are defined inside the service() method so they are, in effect, ONLY available inside JSP scriptlet sections.

If you are running on Tomcat, for instance, you can look at the actual generated Java code for your JSP pages if you look inside the "work" directory in the Tomcat installation. Might be interesting, if not get a better picture about what is happening "under the hood".

2 of 2
16

request is accessible inside the scriptlet expressions, because it's an argument of the method in which these expressions are evaluated (_jspService). But if you want it to be available in your own methods, you must declare it as an argument:

<%
    String fname = request.getParameter("fname");
    String username = getVal("lname", request);
%>
<%!
    private String getVal(String param, HttpServletRequest request) {
        return request.getParameter("fname");
    }
%>

Note that you shouldn't be using scriptlets and getting request parameters in JSPs in the first place. JSPs should be used to generate markup. Do your processing in a servlet/action, prepare the data to be displayed by the JSP by creating and populating beans in the request scope, and then dispatch to a JSP, which should use JSP EL, the JSTL and other custom tags exclusively.

🌐
Starter Tutorials
startertutorials.com › home › programming › advanced java › jsp › create a jsp page to request implicit object
Create a JSP page to request implicit object - Startertutorials
October 24, 2025 - In JSP, config is an implicit object of type ServletConfig. This object can be used to get initialization parameter for a particular JSP page.
🌐
BeginnersBook
beginnersbook.com › 2013 › 11 › jsp-implicit-object-request-with-examples
Request Implicit Object in JSP with examples
March 21, 2017 - For example I have an attribute password and a String object str which has a value “admin” then calling request.setAttribute(“password”, str) would assign a value admin to the attribute password. removeAttribute(String) – By using this method a attribute can be removed and cannot be used further. For e.g. If you have a statement request.removeAttribute(“userid”) on a JSP page then the userid attribute would be completely removed and request.getAttribute(“userid”) would return NULL if used after the removeAttribute method.
🌐
Oracle
forums.oracle.com › ords › apexds › post › request-object-in-jsp-el-6203
Request object in JSP EL
Oracle REST Data Services (ORDS) is the HTTPS Web Gateway for your Oracle Database. Features include SQL Developer Web, Oracle APEX access, REST APIs for your data and databases, Oracle Database API for MongoDB, and much more · Develop REST APIs, PL/SQL, MLE JavaScript, JSON, run SQL and scripts, ...
🌐
Apache
struts.apache.org › core-developers › accessing-application-session-request-objects
Accessing application, session, request objects
The best way to access Request, ... ... public class MyAction implements ApplicationAware { private Map<String, Object> application; public void withApplication(Map<String, Object> application) { this.application = application; } public String execute() { application.set("myKey", "myValue"); ...
🌐
TutorialsPoint
tutorialspoint.com › what-is-a-request-object-in-jsp
What is a request object in JSP?
The request object is an instance of a javax.servlet.http.HttpServletRequest object. Each time a client requests a page, the JSP engine creates a new object to represent that request. The request object provides methods to g
🌐
Oracle
docs.oracle.com › cd › B13224_01 › web.904 › b10320 › genlovw.htm
General JSP Overview
The request object, like the other implicit objects, is available automatically; it is not explicitly instantiated. Objects in a JSP page, whether explicit or implicit, are accessible within a particular scope.
🌐
C# Corner
c-sharpcorner.com › blogs › request-object-in-jsp1
Request object in JSP
September 17, 2011 - This is an object of javax.servlet.httpServletRequest.This object is available as the first parameter of _jspService () method present in the servlet generated behind the jsp. All methods of httpservletRequest can be used upon request object.
🌐
Quora
quora.com › How-can-I-pass-an-object-from-JSP-to-a-servlet
How to pass an object from JSP to a servlet - Quora
Answer: JSP once executes gets delivered to client side. Now one way of talking back to a servlet is to send an HTTP request. You can also do redirects, simply put your object into session, hit a redirct to your servlet and take the data back out from session once you reach in the servlet. (But ...
🌐
EDUCBA
educba.com › home › software development › software development tutorials › java technology tutorial › jsp request
JSP request | How did requests work in JSP with example?
April 15, 2023 - JSP Request is an object from the HttpServletRequest library. This is present implicit to the main class named in the former sentence. The request object is used to pass a lot of information while data flows from one page to another over the net.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Coderanch
coderanch.com › t › 352220 › Servlets › java › jsp-request-object
jsp request object (Servlets forum at Coderanch)
You can refer to request as a javax.servlet.HttpServletRequest object. There is a nice syntax summary document in PDF form you can download from java.sun.com that has stuff like this. Bill ------------------ author of: ... "mrsmithq" your name doesn't agree with the javaranch guidelines. please take a moment and re-register after reviewing the guidelines at http://www.javaranch.com/name.jsp thanks for your cooperation.
🌐
Tpoint Tech
tpointtech.com › request-implicit-object
JSP request implicit object - Tpoint Tech
&gt;&gt; &lt;&lt; 3) JSP response implicit object In JSP, response is an implicit object of type HttpServletResponse. The instance of HttpServletResponse is created by the web container for each jsp request. It can be used to add or manipulate response such as redirect response to another resource, ...
🌐
javakeypoint
javakeypoint.wordpress.com › 2016 › 04 › 04 › jsp-response-object
JSP response object | javakeypoint
April 4, 2016 - JSP response object JSP response implicit object is instance of javax.servlet.http.HttpServletResponse. The instance of HttpServletResponse is created by the web container for each jsp request.It is basically used to sent response to the client(browser) after processing the request.
🌐
Spiceworks
community.spiceworks.com › programming & development
object into string using jsp - Programming & Development - Spiceworks Community
November 26, 2009 - hi I have retrived the data from db in servlet and stored the data in list of beanclass. In servlet ,using setattribute()–set the values In Jsp , Using getattribute() – get the values in jsp my problem is it prints the values in object format Output :[BeanClass@1fc6e42, BeanClass@1fc6e42, ...