Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-12-2012, 07:29 PM   PM User | #1
hym1988
New to the CF scene

 
Join Date: Dec 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
hym1988 is an unknown quantity at this point
button > onclick > chart open

Hello fellows!
I have question.
Iam doing some project to my school and I have small problem.

I have chart (iam using jfreechart) in Chart.java file and after user is loading to his profe he should be able to push button and chart wit his statistics should appear. My problem is that I cant form proper onClick function. or mayby
Code:
window.parent.location.href
is wrong used?

here is code of website when user logged in and he can click on chart button
Code:
<%@ page contentType="text/html; charset=iso-8859-1" language="java"%>
<%@ page import ="java.sql.*" %>
<%@ page import ="javax.sql.*" %>
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css"> 
<script src="../WEB-INF/lib/amcharts.js" type="text/javascript"></script> 
<title>Successfully Login by JSP</title>
        
</head>

<body>
    
<input type=button onClick="parent.location='logOut.jsp'" value='Wyloguj'>

<br>
Zalogowano pomyslnie<br />
Twoje dane :<br />
<%
out.print("Nazwa uzytkownika :<b>"+session.getAttribute("sUserID")+ "</b>"+"<br>");
out.print("Imie i Nazwisko :<b>"+session.getAttribute("sUserName")+"</b>"+"<br>");
out.print("E-mail :<b>"+session.getAttribute("sEmail")+"</b>");
%>



<form action="nowe_dane.jsp" method="post">
<input type="text" name="wynik_badania" /> Poziom cukru z dnia:
<script language="javascript"> 
<!-- 
today = new Date(); 
document.write(" ", today.getDate(),"/",today.getMonth()+1,"/",today.getYear()); 
//--> 
</script> <br>
 <input type="submit" />
<input type=button onClick="window.parent.location.href = 'src/java/demo/Chart.java' " value='Wykres'>

 


</body>
</html>


hym1988 is offline   Reply With Quote
Old 12-12-2012, 09:41 PM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
language=javascript" and document.write have both been obsolete for many years. The <!-- --> around the script is there to hide it from Internet Explorer 2.

Also input tags are required to be inside forms.

None of that would be preventing the new .java page loading when someone clicks on the button though.

The problem is probably on the server in connection with how you have it set to serve .jsp and .java pages.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 12-12-2012, 11:27 PM   PM User | #3
hym1988
New to the CF scene

 
Join Date: Dec 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
hym1988 is an unknown quantity at this point
For tests Iam using chrome,
When Iam putting for example reg.html or newhtml.html into this onClick form it works perfect, iam just having troubles with Chart.java . Also if I "Run" Chart.java window applet is showing up - so if its stands alone it works too!.

Iam just having problem with connecting them... ;x

Quote:
The problem is probably on the server in connection with how you have it set to serve .jsp and .java pages.
Can you say somethink more about it?
hym1988 is offline   Reply With Quote
Old 12-12-2012, 11:49 PM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,585
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
I don’t know where to move that thread. To JS or Java? In any case, this seems to have nothing to do with HTML or CSS.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 12-13-2012, 08:48 AM   PM User | #5
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by VIPStephan View Post
I don’t know where to move that thread. To JS or Java? In any case, this seems to have nothing to do with HTML or CSS.
The JavaScript is irrelevant - all it is doing is calling for a new Java page to load - so this question is more likely to be a problem with the Java code that hasn't been supplied.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 12-14-2012, 06:33 PM   PM User | #6
hym1988
New to the CF scene

 
Join Date: Dec 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
hym1988 is an unknown quantity at this point
mayby there should be some extra informations in web.xml file to run this Chart.java in browser?
hym1988 is offline   Reply With Quote
Old 12-14-2012, 07:32 PM   PM User | #7
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
what does Chart.java class look like?
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote
Old 12-14-2012, 09:52 PM   PM User | #8
hym1988
New to the CF scene

 
Join Date: Dec 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
hym1988 is an unknown quantity at this point
Code:
package demo;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.jdbc.JDBCCategoryDataset;
import org.jfree.ui.*;

public class Chart
{
        public static void main(String[] args) throws Exception 
        {
                String query = "SELECT Category, value from pieData2";
                JDBCCategoryDataset dataset = new JDBCCategoryDataset(
                                "jdbc:mysql://localhost:3306/tabela", "com.mysql.jdbc.Driver",
                                "root", "root");

                dataset.executeQuery(query);
                JFreeChart chart = ChartFactory.createLineChart("Badanie Poziomu Cukru", "Numer Badania", "Poziom cukru",
                                dataset, PlotOrientation.VERTICAL, true, true, false);
                ChartPanel chartPanel = new ChartPanel(chart);
                chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
                ApplicationFrame f = new ApplicationFrame("Chart");
                f.setContentPane(chartPanel);
                f.pack();
                f.setVisible(true);
        }
}
hym1988 is offline   Reply With Quote
Old 12-17-2012, 10:14 AM   PM User | #9
hym1988
New to the CF scene

 
Join Date: Dec 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
hym1988 is an unknown quantity at this point
bump ?
hym1988 is offline   Reply With Quote
Old 12-17-2012, 01:59 PM   PM User | #10
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
why are there hard coded values in there?! I am assuming this is an prebuilt skeleton that is an example- you most likely have to change values around to get it to work. Also this now dives into other classes. Wherever you got that library from they should have tutorials on how to use it.
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:04 PM.


Advertisement
Log in to turn off these ads.