Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

error in java web server  RSS feed

 
felix thomas
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i got this error when i ran this jsp in JWs 2.0
but it works fine in tomcat
could anyone help me in this regard

<%@ page errorPage="errorpage.jsp" %>
<html>
<head>
<title>UseSession</title>
</head>
<body>
<%
// Try and get the current count from the session
Integer count = (Integer)session.getAttribute("COUNT");

// If COUNT is not found, create it and add it to the session
if ( count == null ) {

count = new Integer(1);
session.setAttribute("COUNT", count);
}
else {

count = new Integer(count.intValue() + 1);
session.setAttribute("COUNT", count);
}
// Get the User's Name from the request
out.println("<b>Hello you have visited this site: "
+ count + " times.</b>");
%>
</body>
</html>
the error displayed is :

500 Internal Server Error
Java Server Page Translation Error
Error during compilation :
D:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_UseSession.java:73: Method getAttribute(java.lang.String) not found in interface javax.servlet.http.HttpSession.
Integer count = (Integer)session.getAttribute("COUNT");
^
D:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_UseSession.java:79: Method setAttribute(java.lang.String, java.lang.Integer) not found in interface javax.servlet.http.HttpSession.
session.setAttribute("COUNT", count);
^
D:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_UseSession.java:84: Method setAttribute(java.lang.String, java.lang.Integer) not found in interface javax.servlet.http.HttpSession.
session.setAttribute("COUNT", count);
^
3 errors

 
chin josei
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hii..
JavaWebServer 2.0 uses older version of servlet.
Try using getValue() & setValue() instead of
getAttribute() & setAttribute().
Hope this helps
chin
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or just don't use jws. As a product, it has been cancellend and supersceded by Tomcat.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!