954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

error: The value for the useBean class attribute is invalid

<html>
<head>
<title>Pie Chart Demo</title>
</head>
 
<jsp:useBean id="myChart"  class="classes.beans.votepie" scope="session" />
 
<body>
<h2>Vote Results Pie-chart</h2>
 
<%String chartViewer = myChart.getvoteserve(request, response);%>
 
<img src="<%=chartViewer%>" border=0 usemap="#imageMap">
 
</body>
</html>

accessing this above viewrst.jsp file shows the following error:

<strong>HTTP Status 500 - </strong>

<strong>type</strong> Exception report
<strong>message</strong> 
<strong>description</strong> The server encountered an internal error () that prevented it from fulfilling this request.
<strong>exception</strong> 
org.apache.jasper.JasperException: /viewrst.jsp(6,0) The value for the useBean class attribute classes.beans.votepie is invalid.
	org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
	org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
	org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
	org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
	org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155)
	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
	org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
	org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
	org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
	org.apache.jasper.compiler.Generator.generate(Generator.java:3394)
	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


this is theweb.xml file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
 
<web-app>
  <servlet>
    <servlet-name>voteserve</servlet-name>
    <servlet-class>classes.servlets.voteserve</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>voteserve</servlet-name>
    <url-pattern>/servlet/voteserve</url-pattern>
  </servlet-mapping>
</web-app>


.......what or where is going wrong..please help

apontutul
Light Poster
38 posts since Nov 2006
Reputation Points: 10
Solved Threads: 1
 

giving all the concerned files so that it will be helpful for u to understand.
this is the bean file:votepie.java. it is used to create a chart. the class file is under WEB-INF/classes/beans folder.

<strong>package</strong> classes.beans;
 
<strong>import</strong> java.sql.Connection;
<strong>import</strong> java.sql.DriverManager;
<strong>import</strong> java.sql.*;
<strong>import</strong> org.jfree.data.jdbc.*;
<strong>import</strong> org.jfree.data.general.*;
 
<strong>import</strong> java.io.*;
<strong>import</strong> java.awt.*;
<strong>import</strong> java.util.*;
<strong>import</strong> java.awt.image.*;
<strong>import</strong> org.jfree.data.*;
<strong>import</strong> org.jfree.chart.*;
<strong>import</strong> org.jfree.chart.plot.*;
<strong>import</strong> org.jfree.chart.urls.*;
<strong>import</strong> org.jfree.chart.entity.*;
<strong>import</strong> javax.servlet.*;
<strong>import</strong> javax.servlet.http.*;
<strong>import</strong> org.jfree.data.general.DefaultPieDataset;
<strong>import</strong> org.jfree.chart.ChartFactory;
<strong>import</strong> org.jfree.chart.ChartUtilities.*;
<strong>import</strong> org.jfree.chart.imagemap.*;
<strong>import</strong> java.io.PrintWriter.*;
<strong>import</strong> java.lang.String.*;
<strong>import</strong> org.jfree.chart.ChartRenderingInfo.*;
 
 
 
<strong>public</strong> <strong>class</strong> votepie {
	
	
	PreparedStatement st;
	
			
	<strong>public</strong> PieDataset readData() {
		
		JDBCPieDataset data = <strong>null</strong>;
		String url = "jdbc:mysql://localhost/vote";
		Connection con;
		<strong>try</strong> {
		Class.forName("com.mysql.jdbc.Driver");
		}
		<strong>catch</strong> (ClassNotFoundException e) {
		System.err.print("ClassNotFoundException: ");
		System.err.println(e.getMessage());
		}
		 
		<strong>try</strong> {
			ResultSet rs = st.executeQuery();
			<strong>int</strong> id = rs.getInt("poll_id");
		con = DriverManager.getConnection(url, "vote", "vote001");
		data = <strong>new</strong> JDBCPieDataset(con);
				
		st  = con.prepareStatement ("SELECT option_text, counter FROM VOTE_VOTES where poll_id=?");
		st.setInt(1, id);
		rs = st.executeQuery();
				
		//data.executeQuery(sql);
		con.close();
		}
		<strong>catch</strong> (SQLException e) {
		System.err.print("SQLException: ");
		System.err.println(e.getMessage());
		}
		<strong>catch</strong> (Exception e) {
		System.err.print("Exception: ");
		System.err.println(e.getMessage());
		}
		<strong>return</strong> data;
		}
	
	
	<strong>public</strong> String getChartViewer(HttpServletRequest request, HttpServletResponse response) {
	    votepie pd = <strong>new</strong> votepie();
		
	    // create the chart...
	    JFreeChart chart = ChartFactory.createPieChart(
	          "Vote Result Pie Chart",  // chart title
	          pd.readData(),             // data
	          true,                // include legend
	          true,
	          <strong>false</strong>
	    );
 
	    // set the background color for the chart...
	    chart.setBackgroundPaint(Color.cyan);
	    PiePlot plot = (PiePlot) chart.getPlot();
	    plot.setNoDataMessage("No data available");
	     
	    // set drilldown capability...
	    //plot.setURLGenerator(new StandardPieURLGenerator("Bar3DDemo.jsp","section"));
	    //plot.setLabelGenerator(null);
 
	    // OPTIONAL CUSTOMISATION COMPLETED.
 
	    ChartRenderingInfo info = <strong>null</strong>;
	    HttpSession session = request.getSession();
	    <strong>try</strong> {
 
	      //Create RenderingInfo object
	      response.setContentType("text/html");
	      info = <strong>new</strong> ChartRenderingInfo(<strong>new</strong> StandardEntityCollection());
	      BufferedImage chartImage = chart.createBufferedImage(640, 400, info);
 
	      // putting chart as BufferedImage in session, 
	      // thus making it available for the image reading action Action.
	      session.setAttribute("chartImage", chartImage);
 
	      PrintWriter writer = <strong>new</strong> PrintWriter(response.getWriter());
	      ChartUtilities.writeImageMap(writer, "imageMap", info, <strong>true</strong>);
	      writer.flush();
	    
	    }
	    <strong>catch</strong> (Exception e) {
	       // handle your exception here
	    }
	   
	    String pathInfo = "http://";
	    pathInfo += request.getServerName();
	    <strong>int</strong> port = request.getServerPort();
	    pathInfo += ":"+String.valueOf(port);
	    pathInfo += request.getContextPath();
	    String chartViewer = pathInfo + "/servlet/ChartViewer";
	    <strong>return</strong> chartViewer;
	  }
	}


this is theservlet file: voteserve.java..the class file is under WEB-INF/classes/servlets folder.

<strong>package</strong> classes.servlets;
 
<strong>import</strong> java.io.*;
<strong>import</strong> java.awt.image.*;
<strong>import</strong> javax.servlet.*;
<strong>import</strong> javax.servlet.http.*;
<strong>import</strong> com.keypoint.PngEncoder;
 
<strong>public</strong> <strong>class</strong> voteserve <strong>extends</strong> HttpServlet {
 
	  <strong>public</strong> <strong>void</strong> init() <strong>throws</strong> ServletException {
	  }
 
	  //Process the HTTP Get request
	  <strong>public</strong> <strong>void</strong> doGet(HttpServletRequest request, HttpServletResponse response)
	         <strong>throws</strong> ServletException, IOException {
 
	   // get the chart from session
	   HttpSession session = request.getSession();
	   BufferedImage chartImage = (BufferedImage) session.getAttribute("chartImage");
 
	   // set the content type so the browser can see this as a picture
	   response.setContentType("image/png");
 
	   // send the picture
	   PngEncoder encoder = <strong>new</strong> PngEncoder(chartImage, false, 0, 9);
	   response.getOutputStream().write(encoder.pngEncode());
	   
	  }
 
	  //Process the HTTP Post request
	  <strong>public</strong> <strong>void</strong> doPost(HttpServletRequest request, HttpServletResponse response)
	         <strong>throws</strong> ServletException, IOException {
	    doGet(request, response);
	  }
 
	  //Process the HTTP Put request
	  <strong>public</strong> <strong>void</strong> doPut(HttpServletRequest request, HttpServletResponse response)
	         <strong>throws</strong> ServletException, IOException {
	  }
 
	  //Clean up resources
	  <strong>public</strong> <strong>void</strong> destroy() {
	  }
 
	}


guys please plz help me out....thanks

apontutul
Light Poster
38 posts since Nov 2006
Reputation Points: 10
Solved Threads: 1
 

Also I have the same problem in my project, but I'm sure that the connection is satisfied with my access data Base , because the project execute only file that retrieve data from the data Base, but it doesn't execute the other functions of log-in , update & delete functions.
Here is the error for the log in page:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /jsp/MemberLogin.jsp(11,0) The value for the useBean class attribute com.mySite.Memberbean is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1223)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3270)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:189)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.

safaa
Newbie Poster
1 post since Mar 2008
Reputation Points: 10
Solved Threads: 0
 

am also having the same problem, trying to upload a photo and this is the error that am getting

The value for the useBean class attribute javazoom.upload.UploadBean is invalid;

this is the code:

<html>
<body bgcolor="#333333">

<%@ page language="java" import="javazoom.upload.UploadBean*,java.util.*,java.io.*" %>
<%@ page errorPage="ExceptionHandler.jsp" %>

<% String directory = "c:/Missing Person"; %>
<% String tmpdirectory = "c:/Missing Person/tmp"; %>
<% boolean createsubfolders = true; %>
<% boolean allowresume = true; %>
<% boolean allowoverwrite = true; %>
<% String encoding = "ISO-8859-1"; %>
<% boolean keepalive = false; %>

<jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
  <jsp:setProperty name="upBean" property="folderstore" value="<%= directory %>" />
  <jsp:setProperty name="upBean" property="parser" value="<%= MultipartFormDataRequest.CFUPARSER %>"/>
  <jsp:setProperty name="upBean" property="parsertmpdir" value="<%= tmpdirectory %>"/>
  <jsp:setProperty name="upBean" property="filesizelimit" value="8589934592"/>
  <jsp:setProperty name="upBean" property="overwrite" value="<%= allowoverwrite %>"/>
  <jsp:setProperty name="upBean" property="dump" value="true"/>
</jsp:useBean>

<%
  //request.setCharacterEncoding(encoding);
  //response.setContentType("text/html; charset="+encoding);
  String method = request.getMethod();
  // Head processing to support resume and overwrite features.
  if (method.equalsIgnoreCase("head"))
  {
    String filename = request.getHeader("relativefilename");
    if (filename == null) filename = request.getHeader("filename");
    if (filename!=null)
    {
    	if (keepalive == false) response.setHeader("Connection","close");
    	String account = request.getHeader("account");
 	if (account == null) account="";
    	else if (!account.startsWith("/")) account = "/"+account;
    	File fhead = new File(directory+account+"/"+filename);
    	if (fhead.exists())
    	{
    	   response.setHeader("size", String.valueOf(fhead.length()));
    	   String checksum = request.getHeader("checksum");
    	   if ((checksum != null) && (checksum.equalsIgnoreCase("crc")))
    	   {
		long crc = upBean.computeCRC32(fhead,-1);
		if (crc != -1) response.setHeader("checksum", String.valueOf(crc));
    	   }
    	   else if ((checksum != null) && (checksum.equalsIgnoreCase("md5")))
    	   {
		String md5 = upBean.hexDump(upBean.computeMD5(fhead,-1)).toLowerCase();
		if ((md5 != null) && (!md5.equals(""))) response.setHeader("checksum", md5);
    	   }
    	}
    	else response.sendError(HttpServletResponse.SC_NOT_FOUND);
       return;
    }
  }
%>
<html>
<head>
<title>Samples : Large Upload + jClientUpload Applet support</title>
<style TYPE="text/css">
<!--
.style1 {
	font-size: 12px;
	font-family: Verdana;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=<%= encoding %>">




<script language="Javascript"><!--
  
  function doClean()
  {
    document.upload.todo.value="cleanstore";
	document.upload.submit();
  }
  //--></script>
</head>
<body>
<ul class="style1">
<%
      if (MultipartFormDataRequest.isMultipartFormData(request))
      {
         // Parse multipart HTTP POST request.
         MultipartFormDataRequest mrequest = null;
         try
         {
         	mrequest = new MultipartFormDataRequest(request,null,-1,MultipartFormDataRequest.CFUPARSER,encoding,allowresume);
         } catch (Exception e)
	   {
	       // Cancel current upload (e.g. Stop transfer)
               // Only if allowresume = false
	   }
         String todo = null;
         if (mrequest != null) todo = mrequest.getParameter("todo");
         if ( (todo != null) && (todo.equalsIgnoreCase("upload")) )
         {
    	   String account = mrequest.getParameter("account");
    	   if (account == null) account="";
    	   else if (!account.startsWith("/")) account = "/"+account;
           upBean.setFolderstore(directory+account);
           Hashtable files = mrequest.getFiles();
           if ( (files != null) && (!files.isEmpty()) )
           {
             UploadFile file = (UploadFile) files.get("uploadfile");
              if (file != null) out.println("<b> Successfully Uploaded the Missing Person's photo : "+file.getFileName());
                    // Folders and subfolders creation support.
             String relative = mrequest.getParameter("relativefilename");
             if ((createsubfolders == true) && (relative != null))
             {
               int inda=relative.length();
               int indb=file.getFileName().length();
               if (inda > indb)
               {
                 String subfolder = relative.substring(0,(inda-indb)-1);
                 subfolder = subfolder.replace('\\','/').replace('/',java.io.File.separatorChar);
                 upBean.setFolderstore(directory+account+java.io.File.separator+subfolder);
               }
             }
             if (keepalive == false) response.setHeader("Connection","close");
             // Chunks recomposion support.
             String chunkidStr = mrequest.getParameter("chunkid");
             String chunkamountStr = mrequest.getParameter("chunkamount");
             String chunkbaseStr = mrequest.getParameter("chunkbase");
             if ((chunkidStr != null) && (chunkamountStr != null) && (chunkbaseStr != null))
             {
               // Always overwrite chunks.
               upBean.setOverwrite(true);
               upBean.store(mrequest, "uploadfile");
               upBean.setOverwrite(allowoverwrite);
               int chunkid = Integer.parseInt(chunkidStr);
               int chunkamount = Integer.parseInt(chunkamountStr);
               if (chunkid == chunkamount)
               {
                 // recompose file.
                 String fname = upBean.getFolderstore()+java.io.File.separator+chunkbaseStr;
                 File fread = new File(fname);
                 if (fread.canRead() && (upBean.getOverwrite()==false)) fname = upBean.loadOverwriteFilter().process(fname);
                 FileOutputStream fout = new FileOutputStream(fname);
                 byte[] buffer = new byte[4096];
                 for (int c=1;c<=chunkamount;c++)
                 {
                   File filein = new File(upBean.getFolderstore()+java.io.File.separator+chunkbaseStr+"."+c);
                   FileInputStream fin = new FileInputStream(filein);
                   int read = -1;
                   while ((read = fin.read(buffer)) > 0) fout.write(buffer,0,read);
                   fin.close();
                   filein.delete();
                 }
                 fout.close();
               }
             }
             else upBean.store(mrequest, "uploadfile");
             upBean.setFolderstore(directory+account);
           }
           else
           {
             String emptydirectory = mrequest.getParameter("emptydirectory");
             if ((emptydirectory != null) && (!emptydirectory.equals("")))
             {
               File dir = new File(directory+account+"/"+emptydirectory);
               dir.mkdirs();
             }
             out.println("<li>No uploaded files");
           }
         }
         
		 else if ( (todo != null) && (todo.equalsIgnoreCase("cleanstore")) )
	     {
            upBean.resetStore();
            out.println("<BR>Store cleaned");
         }
  		 
      }
%>
</ul>
<form method="post" action="umLargeUpload.jsp" name="upform" enctype="multipart/form-data">
  <table width="60%" border="0" cellspacing="1" cellpadding="1" align="center" class="style1">
    <tr>
      <td align="left"><b>Select a file to upload :</b></td>
    </tr>
    <tr>
      <td align="left">
        <input type="hidden" name="todo" value="upload">
          <input type="file" name="uploadfile" size="50">
      </td>
    </tr>
    <tr>
      <td align="left">
        <input type="submit" name="Submit" value="Upload">
        <input type="reset" name="Reset" value="Cancel">
      </td>
    </tr>
  </table>
  <p>&nbsp;</p>
</form>
</body>
</html>


please help

victabk
Newbie Poster
3 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You