•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 402,550 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,304 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1559 | Replies: 3 | Solved
![]() |
hi guys......i want to view a piechart extracting items from a mysql database. i've created a button on a jsp page(view.jsp) which is calling another jsp page(viewrst.jsp) when i click that. the code for (viewrst.jsp) is given below:
& i'm getting this error when I click the button:
is the prob related to classpath variables?the java is working when i run it, but not in jsp. please suggest what to do?......thankz.
<%@ page language="java"%> <%@page import="org.jfree.chart.*;"%> <%@page import="java.sql.DriverManager;"%> <%@page import="java.sql.*;"%> <%@page import="org.jfree.data.jdbc.*;"%> <%@page import="org.jfree.data.general.*;"%> <%! public class votepie { /** * @param args */ private PieDataset readData() { JDBCPieDataset data = null; String url = "jdbc:mysql://localhost/vote"; Connection con; try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url, "vote", "vote001"); data = new JDBCPieDataset(con); String sql = "SELECT option_text, counter FROM VOTE_VOTES where poll_id=1;"; data.executeQuery(sql); con.close(); } catch (SQLException e) { System.err.print("SQLException: "); System.err.println(e.getMessage()); } catch (Exception e) { System.err.print("Exception: "); System.err.println(e.getMessage()); } return data; } public static void main(String[] args) { // TODO Auto-generated method stub votepie pd = new votepie(); pd.readData(); //creating the chart JFreeChart chart = ChartFactory.createPieChart( "Sample Pie Chart", pd.readData(), true, // legend? true, // tooltips? false // URLs? ); // create and display a frame... ChartFrame frame = new ChartFrame("First", chart); frame.pack(); frame.setVisible(true); } } %>
& i'm getting this error when I click the button:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 44 in the jsp file: /viewrst.jsp
The method main cannot be declared static; static methods can only be declared in a static or top level type
41: }
42: return data;
43: }
44: public static void main(String[] args) {
45: // TODO Auto-generated method stub
46:
47: votepie pd = new votepie();
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
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)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
Apache Tomcat/6.0.10
is the prob related to classpath variables?the java is working when i run it, but not in jsp. please suggest what to do?......thankz.
Last edited by apontutul : Sep 3rd, 2007 at 4:55 pm.
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,230
Reputation:
Rep Power: 10
Solved Threads: 270
Hmmmmm interesting, I would never say that main method bellong to JSP...
...or is this new programming approach?
...or is this new programming approach?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,230
Reputation:
Rep Power: 10
Solved Threads: 270
JSP has no "main" method in its body!
If you wish to execute something you should use SERVLET and outcome pass to another JSP page. You may want to have go on this tutorial http://java.sun.com/javaee/5/docs/tutorial/doc/
If you wish to execute something you should use SERVLET and outcome pass to another JSP page. You may want to have go on this tutorial http://java.sun.com/javaee/5/docs/tutorial/doc/
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access activation api blogger blogging blogs code coding com combo compilers dani daniweb data debugging development dreamweaver dropdownlist errors gdata google gpl html innovation java key languages linux microsoft microsoft sdk for java microsystems module net news open openbsd platform product programming reuse rss serial software source sun tags vista web xml
- How to Connect MySQL from JSP Page (JSP)
- Very Very Urgent...Need Code for Calculating Execution Time For Jsp Page (JSP)
- including java programs or code in jsp (JSP)
- java bean (JSP)
- how to call javabean from jsp page upon onChange event (JSP)
- Move out java code from jsp (Java)
- Using a Java Object in a JSP (Java)
- date time issue in JSP (JSP)
- Adapting a Java Application to JSP/Servlets (Java)
Other Threads in the JSP Forum
- Previous Thread: generating dynamic/runtime query
- Next Thread: server



Linear Mode