<context-param>
<param-name>productSearchRPP</param-name>
<param-value>8</param-value>
</context-param>
I want to get value of productSearchRPP in products.jsp page
To access the values from your Java/JSP code, use the following syntax: String value = getServletContext(). getInitParameter("parameterName"); A single <context-param> tag is used for each parameter.
In short, to get Request Parameters in a JSP page you should: Create a jsp page that begins with the <%code fragment%> scriptlet. It can contain any number of JAVA language statements, variable or method declarations, or expressions that are valid in the page scripting language.
Context parameters are additional value pairs that are sent to your app in the request URL from the host application. Using context parameters, your apps can selectively alter their behavior based on information provided by the application.
The page directive is used to provide instructions to the container that pertain to the current JSP page. You may code the page directives anywhere in your JSP page. By convention, page directives are coded at the top of the JSP page. Following is the basic syntax of page directive − <%@ page attribute = "value" %>
Even you can try this in your jsp.
ServletContext context = pageContext.getServletContext();
com = context.getInitParameter("com");
and with jstl you can use.
${initParam['theStringIWant']}
pageContext.getServletContext().getInitParameter("key");
This is how you get context parameter value in JSP. In JSTL you can get it like this
${pageContext.servletContext}
Or
${applicationScope.attributeName}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With