Discussion:
cannot evaluate pageContext.request.method
William Norman
14 years ago
Permalink
Hello,

I have written some jsp's using Netbeans 7.0. In a self-referencing jsp
I want to perform a test to do further processing on the submitted page
like this:

<c:if test="${pageContext.request.method=='POST'}">

<!-- some sql insert code -->
</c:if>


My problem is that the IDE does not recognize
pageContext.request.method. When I try to use code completion, method is
not available. Also, if I type in the complete statement I see a warning
on the page that states 'Unknown property "method"'.

Running the code bypasses the conditional and a adding simple

<c:out value="${pageContext.request.method}"/>

statement to the page produces no output text.

I have tried this same code in Eclipse using the same jstl libs and web
server environment and it works fine. I tried searching the web for this
issue but could not find any postings. I could not get it work using
Netbeans 6.9 either.

I must be referencing an incorrect library somewhere, but I'll be darned
if I can see the problem.

Any thoughts?

Thanks
--
Bill
markwade
14 years ago
Permalink
I have tried this same code in Eclipse using the same jstl libs and web server environment and it works fine. I tried searching the web for this issue but could not find any postings. I could not get it work using Netbeans 6.9 either.
I must be referencing an incorrect library somewhere, but I'll be darned if I can see the problem.
--
Bill
You didn't say if you included the JSTL 1.1 library in your project's properties. Is that how you are referencing the jstl libs in NetBeans?

-- Mark
wsnorman
14 years ago
Permalink
The jstl 1.1 libraries are included in my netbeans project. All other jstl
statements work fine in this project.

--
View this message in context: http://netbeans-org.1045718.n5.nabble.com/cannot-evaluate-pageContext-request-method-tp4788389p4790649.html
Sent from the Netbeans IDE Users mailing list archive at Nabble.com.
markwade
14 years ago
Permalink
Sorry I can't be of any help.


Code:

<c:if test="${pageContext.request.method == 'POST'}">
<!-- some sql insert code -->
</c:if>




doesn't work. I tried Tomcat 6 and 7 and GlassFish 3.1 and a couple of
different jstl libs 1.1 and 1.2 with the same results.
There doesn't seem to be a property "method" in ServletRequest.

This works:


Code:

<%
if(((HttpServletRequest) pageContext.getRequest()).getMethod().equalsIgnoreCase("POST")){

// some sql insert code

}

%>




But you probably knew that and it doesn't help.

Odd that it works in Eclipse with the same libs. The "missing" property, "method" is in the server libs not the jstl libs though
so it would seem it would have to be something in the server implementation.

I've seen examples such as:



Code:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Example - Get HTTP Request Information</title>
</head>
<body>
<pre>
Method: ${pageContext.request.method}
Query String: ${pageContext.request.queryString}
Request URI: ${pageContext.request.requestURI}
Request URL: ${pageContext.request.requestURL}
Servlet Path: ${pageContext.request.servletPath}
</pre>
</body>
</html>




But I can't get any of that working in NetBeans. Those ServletRequest properties just aren't implemented in the servers
I have installed and I haven't been able to figure out where they are implemented.

If you figure it out, please post the answer.

-- Mark

Loading...