What is wrong with this code? please help

Hello,
Please pardon if you find my question too simple. I have the following
code
<form method=get action="page1.jsp">
<input type=hidden name=Id value="<%= rs.getInt("id")%>" >
<input type=hidden name=Title value="<%= rs.getString("title") %>" >
<input type=hidden name=Price value="<%= rs.getDouble("price")%>" >
<input type=submit name=operation value="Add">
</form>
i think they may be a problem here but i don't really know where .
please could someone help me?
Thank you.

<%@page language = "java" import = "java.sql.*,java.lang.String"%>
<html>
<jsp:useBean id="userr" class="temp.Modifier" scope="session"/>
<jsp:setProperty name="userr" property="*"/>
<link href="../style/bleed.css" type="text/css" rel="stylesheet">
<BODY text="#ffffff" link="#00CC66">
<form name="form1" method="post" action="change.jsp">
<table class=Mtable width="81%" border="0">
<%
try {
userr.getConnect();
String sql_stmt = null;
String stu_no = request.getParameter( "stu_no");//get the value that inputed by the operator
String subj_no = request.getParameter("subj_no");
String teacher = request.getParameter("teacher");
String term = request.getParameter("term");
String year = request.getParameter("year");
String stu_class = request.getParameter("class");
String stu_name = request.getParameter("stu_name");
String subj_name = request.getParameter("subj_name");
if(!stu_no.equals("")){
out.println("Stu_no = " + stu_no + ";<br>");
if(!subj_no.equals("")){
out.println("subj_no = " + subj_no + ";<br>");
if(!teacher.equals("")){
out.println("teacher = " + teacher + ";<br>");
if(!term.equals("")){
out.println("term = " + term + ";<br>");
if(!year.equals("")){
out.println("Year = " + year + ";<br>");
if(!stu_class.equals("")){
out.println("Class = " + stu_class + ";<br>");
if(!stu_name.equals("")){
out.println("Stu_name = " + stu_name + ";<br>");
if(!subj_name.equals("")){
out.println("subj_name = " + subj_name + ";<br>");
out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br>the role is :" + userr.getRole());
%>
<tr>
<td width="11%"><div align="center"></div><font color="#3366ff">��  ��</font></div></td>
<td width="11%"><div align="center"><font color="#3366ff">������</font></div></td>
<td width="11%"><div align="center"><font color="#3366ff">��  ��</font></div></td>
<td width="11%"><div align="center"><font color="#3366ff">��  ��</font></div></td>
<td width="11%"><div align="center"><font color="#3366ff">��  ��</font></div></td>
<td width="11%"><div align="center"><font color="#3366ff">��������</font></div></td>
<td width="11%"><div align="center"><font color="#3366ff">��������</font></div></td>
</tr>
<%
sql_stmt = userr.getSqlsentance_search(stu_no,subj_no,teacher, term, year, stu_class, stu_name, subj_name);
ResultSet rrs = userr.stmt.executeQuery(sql_stmt);
//check out how many content the resultset has
int i = 1;
for(i = 1;rrs.next();i++){
userr.setArraylength(i);
rrs.close();
userr.stu_no =new int;//initialize these arrays
userr.sub_no = new int[i];
userr.score = new int[i];
userr.year = new String[i];
userr.teacher = new String[i];
userr.term = new int[i];
userr.status = new int[i];
ResultSet rs = userr.stmt.executeQuery(sql_stmt);//start request the records from the DB
for(i = 1 ;rs.next();i++){
userr.setSub_no(i,rs.getInt(1));
userr.setStu_no(i,rs.getInt(2));
userr.setTerm(i,rs.getInt(3));
userr.setYear(i,rs.getString(4));
userr.setTeacher(i,rs.getString(5));
userr.setStatus(i,rs.getInt(6));
userr.setScore(i,rs.getInt(7));
%>
<tr>
<td><font color="#3366ff"><%out.println(userr.getStu_no(i));%></font></td>
<td><font color="#3366ff"><%out.println(userr.getRole());%></font></td>
<%
if(userr.getRole().equals("admin")){
%>
<td><input class=textfielda type="text" size = 11 name=<%out.println("score_changed"+i);%>size = 10 value = <%=userr.getScore(i)%>></td>
<td><input class=textfielda type="text" size = 11 name=<%out.println("term_changed"+i);%>size = 10 value = <%=userr.getTerm(i)%>></td>
<td><input class=textfielda type="text" size = 11 name=<%out.println("year_changed"+i);%>size = 10 value = <%=userr.getYear(i)%>></td>
<td><input class=textfielda type="text" size = 11 name=<%out.println("status_changed"+i);%>size = 10 value = <%=userr.getStatus(i)%>></td>
<td><input class=textfielda type="text" size = 11 name=<%out.println("teacher_changed"+i);%>size = 10 value = <%=userr.getTeacher(i)%>></td>
</tr>
<%
}else if(userr.getRole().equals("opera")){
if(userr.getScore(i) == 0){
%>
<td><input class=textfielda type="text" size = 11 name=<%out.println("score_changed"+i);%>size = 10 value = <%=userr.getScore(i)%>></td>
<%
}else{
%>
<td><%out.println(userr.getScore(i));%></td>
<%
%>
<td><%out.println(userr.getTerm(i));%></td>
<td><%out.println(userr.getYear(i));%> </td>
<td><%out.println(userr.getStatus(i));%> </td>
<td><%out.println(userr.getTeacher(i));%></td>
</tr>
<%
}else{
out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!norole!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
rs.close();
if(!userr.getClose()){
out.println("!!!!!!!!!!!!!!!!!!!DB close failed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
} catch (SQLException e) {
e.printStackTrace();
%>
</table>
<input class=botton name="button" type=submit value=" �� �� ">
</form>
</body>
</html>
I pardon you because I was worse when began, <%= %> instead of "<%= %>"

Similar Messages

  • What is wrong with this code? on(release) gotoAndPlay("2")'{'

    Please could someone tell me what is wrong with this code - on(release)
    gotoAndPlay("2")'{'
    this is the error that comes up and i have tried changing it but it is not working
    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 2: '{' expected
         gotoAndPlay("2")'{'
    Total ActionScript Errors: 1 Reported Errors: 1
    Thanks

    If you have a frame labelled "2" then it should be:
    on (release) {
        this._parent.gotoAndPlay("2");
    or other wise just the following to go to frame 2:
    on (release) {
         this._parent.gotoAndPlay(2);
    You just had a missing curly bracket...

  • I can't figure out what's wrong with this code

    First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
    One two buckle your shoe
    Three four shut the door
    Five six pick up sticks
    Seven eight lay them straight
    Nine ten this is the end.
    The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
    public class PoemSeventeen
    public static void main(String[] args)
    EasyReader console = new EasyReader();
    System.out.println("Enter a number for the poem (0 to quit): ");
    int n = console.readInt();
    if (n = 1) || (n = 2)
    System.out.println("One, two, buckle your shoe");
    else if (n = 3) || (n = 4)
    System.out.println("Three, four, shut the door");
    else if (n = 5) || (n = 6)
    System.out.println("Five, six, pick up sticks");
    else if (n = 7) || (n = 8)
    System.out.println("Seven, eight, lay them straight");
    else if (n = 9) || (n = 10)
    System.out.println("Nine, ten, this is the end");
    else if (n = 0)
    System.out.println("You may exit now");
    else
    System.out.println("Put in a number between 0 and 10");
    I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
    The EasyReader class code:
    // package com.skylit.io;
    import java.io.*;
    * @author Gary Litvin
    * @version 1.2, 5/30/02
    * Written as part of
    * <i>Java Methods: An Introduction to Object-Oriented Programming</i>
    * (Skylight Publishing 2001, ISBN 0-9654853-7-4)
    * and
    * <i>Java Methods AB: Data Structures</i>
    * (Skylight Publishing 2003, ISBN 0-9654853-1-5)
    * EasyReader provides simple methods for reading the console and
    * for opening and reading text files. All exceptions are handled
    * inside the class and are hidden from the user.
    * <xmp>
    * Example:
    * =======
    * EasyReader console = new EasyReader();
    * System.out.print("Enter input file name: ");
    * String fileName = console.readLine();
    * EasyReader inFile = new EasyReader(fileName);
    * if (inFile.bad())
    * System.err.println("Can't open " + fileName);
    * System.exit(1);
    * String firstLine = inFile.readLine();
    * if (!inFile.eof()) // or: if (firstLine != null)
    * System.out.println("The first line is : " + firstLine);
    * System.out.print("Enter the maximum number of integers to read: ");
    * int maxCount = console.readInt();
    * int k, count = 0;
    * while (count < maxCount && !inFile.eof())
    * k = inFile.readInt();
    * if (!inFile.eof())
    * // process or store this number
    * count++;
    * inFile.close(); // optional
    * System.out.println(count + " numbers read");
    * </xmp>
    public class EasyReader
    protected String myFileName;
    protected BufferedReader myInFile;
    protected int myErrorFlags = 0;
    protected static final int OPENERROR = 0x0001;
    protected static final int CLOSEERROR = 0x0002;
    protected static final int READERROR = 0x0004;
    protected static final int EOF = 0x0100;
    * Constructor. Prepares console (System.in) for reading
    public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
    new InputStreamReader(System.in), 128);
    * Constructor. opens a file for reading
    * @param fileName the name or pathname of the file
    public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
    myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
    myErrorFlags |= OPENERROR;
    myFileName = null;
    * Closes the file
    public void close()
    if (myFileName == null)
    return;
    try
    myInFile.close();
    catch (IOException e)
    System.err.println("Error closing " + myFileName + "\n");
    myErrorFlags |= CLOSEERROR;
    * Checks the status of the file
    * @return true if en error occurred opening or reading the file,
    * false otherwise
    public boolean bad()
    return myErrorFlags != 0;
    * Checks the EOF status of the file
    * @return true if EOF was encountered in the previous read
    * operation, false otherwise
    public boolean eof()
    return (myErrorFlags & EOF) != 0;
    private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
    * Reads the next character from a file (any character including
    * a space or a newline character).
    * @return character read or <code>null</code> character
    * (Unicode 0) if trying to read beyond the EOF
    public char readChar()
    char ch = '\u0000';
    try
    if (ready())
    ch = (char)myInFile.read();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (ch == '\u0000')
    myErrorFlags |= EOF;
    return ch;
    * Reads from the current position in the file up to and including
    * the next newline character. The newline character is thrown away
    * @return the read string (excluding the newline character) or
    * null if trying to read beyond the EOF
    public String readLine()
    String s = null;
    try
    s = myInFile.readLine();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (s == null)
    myErrorFlags |= EOF;
    return s;
    * Skips whitespace and reads the next word (a string of consecutive
    * non-whitespace characters (up to but excluding the next space,
    * newline, etc.)
    * @return the read string or null if trying to read beyond the EOF
    public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
    while (ready() && Character.isWhitespace(ch))
    ch = (char)myInFile.read();
    while (ready() && !Character.isWhitespace(ch))
    count++;
    buffer.append(ch);
    myInFile.mark(1);
    ch = (char)myInFile.read();
    if (count > 0)
    myInFile.reset();
    s = buffer.toString();
    else
    myErrorFlags |= EOF;
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    return s;
    * Reads the next integer (without validating its format)
    * @return the integer read or 0 if trying to read beyond the EOF
    public int readInt()
    String s = readWord();
    if (s != null)
    return Integer.parseInt(s);
    else
    return 0;
    * Reads the next double (without validating its format)
    * @return the number read or 0 if trying to read beyond the EOF
    public double readDouble()
    String s = readWord();
    if (s != null)
    return Double.parseDouble(s);
    // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
    return 0.0;
    Can anybody please tell me what's wrong with this code? Thanks

    String[] message = {
        "One, two, buckle your shoe",
        "One, two, buckle your shoe",
        "Three, four, shut the door",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Seven, eight, lay them straight",
        "Nine, ten, this is the end",
        "Nine, ten, this is the end"
    if(n>0)
        System.out.println(message[n]);
    else
        System.exit(0);

  • FileFilter????What's wrong with this code???HELP!!

    I want to limit the JFileChooser to display only txt and java file. But the code I wrote has error and I don't know what's wrong with it. can anyone help me to check it out? Thank you.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class FileFilterTest extends JPanel
         public static void main(String[] args)
              new FileFilterTest();
         public class fFilter implements FileFilter
              public boolean accept(File file)
                   String name = file.getName();
                   if(name.toLowerCase().endsWith(".java") || name.toLowerCase().endsWith(".txt"))
                        return true;
                   else
                        return false;
         public FileFilterTest()
              JFileChooser fc = new JFileChooser();
              fc.setFileFilter(new fFilter());
              fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
              fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
              //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
              //fc.setMultiSelectionEnabled(true);
              int returnVal = fc.showDialog(FileFilterTest.this, "Open File");
              if(returnVal == JFileChooser.APPROVE_OPTION)
                   String file = fc.getSelectedFile().getPath();
                   if(file == null)
                        return;
              else if(returnVal == JFileChooser.CANCEL_OPTION)
                   System.exit(0);
              else
                   System.exit(0);
              JFrame f = new JFrame();
              FileFilterTest ff = new FileFilterTest();
              f.setTitle("FileFilterTest");
              f.setBackground(Color.lightGray);
              f.getContentPane().add(ff, BorderLayout.CENTER);
              f.setSize(800, 500);
              f.setVisible(true);
    }

    There are two file filters
    class javax.swing.filechooser.FileFilter
    interface java.io.FileFilter
    In Swing you need to make a class which extends the first one and implements the second. Sometimes you may not need to implement the second, but it is more versitle to do so and requires no extra work.

  • What's wrong with this code (in recursion there may be a problem )

    // ELEMENTS OF TWO VECTORS ARE COMPARED HERE
    // CHECK WHAT IS WRONG WITH THIS PGM
    // there may be a problem in recursion
    import java.util.*;
    class Test
    Vector phy,db;
    public static void main(String adf[])
         Vector pp1=new Vector();
         Vector dp1=new Vector();
         //adding elements to the vector
         pp1.add("1");
         pp1.add("a");
         pp1.add("b");
         pp1.add("h");
         pp1.add("c");
         dp1.add("q");
         dp1.add("c");
         dp1.add("h");
         dp1.add("w");
         dp1.add("t");
         printVector(dp1);
         printVector(pp1);
         check2Vectors(pp1,dp1);
    public static void printVector(Vector v1)
         System.out.println("Vector size "+v1.size());
         for(int i=0;i<v1.size();i++)
              System.out.println(v1.get(i).toString());
    public static void check2Vectors(Vector p,Vector d)
         System.out.println("p.size() "+p.size()+" d.size() "+d.size());
         printVector(p);
         printVector(d);
         for(int i=0;i<p.size();i++)
                   for(int j=0;j<d.size();j++)
                        System.out.println(" i= "+i+" j= "+j);
                        Object s1=p.elementAt(i);
                        Object s2=d.elementAt(j);
              System.out.println("Checking "+s1+" and "+s2);
                        if(s1.equals(s2))
    System.out.println("Equal and Removing "+s1+" and "+s2);
                             p.remove(i);
                             d.remove(j);
                             printVector(p);
                             printVector(d);                    
                        check2Vectors(p,d);
                   }//inner for
              }//outer for     
    if(p.size()==0||d.size()==0)
    System.out.println("Vector checking finished and both match");
    else
    System.out.println("Vector checking finished and both do not match");
    }//method
    }

    hi,
    but the upper limit is changing everytime you call the function recursively
    so there should not be any problem(i suppose)
    my intension is to get the unmatched elements of the two vectors
    suggest me changes and thanks in advancce
    ashok
    The problems comes from the fact that you remove
    elements for a Vector while iterating in a loop where
    the upper limit as been set to the initial size of the
    Vector.
    You should use so while loops with flexible stop
    conditions that would work when the size of the Vector
    changes.
    Finally: why don't you use Vector.equals() ?

  • What am i doing wrong with this class please help

    What am i doing wrong with this class? I'm trying to create a JFrame with a JTextArea and a ScrollPane so that text can be inserted into the text area. however evertime i run the program i cannot see the textarea but only the scrollpane. please help.
    import java.io.*;
    import java.util.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Instructions extends JFrame{
    public JTextArea textArea;
    private String s;
    private JScrollPane scrollPane;
    public Instructions(){
    super();
    textArea = new JTextArea();
    s = "Select a station and then\nadd\n";
    textArea.append(s);
    textArea.setEditable(true);
    scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    this.getContentPane().add(textArea);
    this.getContentPane().add(scrollPane);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setTitle("Instructions");
    this.setSize(400,400);
    this.setVisible(true);
    }//end constructor
    public static void main(String args[]){
    new Instructions();
    }//end class

    I'm just winging this so it might be wrong:
    import java.io.*;
    import java.util.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Instructions extends JFrame{
    public JTextArea textArea;
    private String s;
    private JScrollPane scrollPane;
    public Instructions(){
    super();
    textArea = new JTextArea();
    s = "Select a station and then\nadd\n";
    textArea.append(s);
    textArea.setEditable(true);
    scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    // Here you already have textArea in scrollPane so no need to put it in
    // content pane, just put scrollPane in ContentPane.
    // think of it as containers within containers
    // when you try to put them both in at ContentPane level it will use
    // it's layout manager to put them in there side by side or something
    // so just leave this out this.getContentPane().add(textArea);
    this.getContentPane().add(scrollPane);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setTitle("Instructions");
    this.setSize(400,400);
    this.setVisible(true);
    }//end constructor
    public static void main(String args[]){
    new Instructions();
    }//end class

  • Help!!! What's wrong with this code. JSP page can't retrieve properties.

    I'v got a piece of code that was created to send some parameters to JSP page via POST method. But in server page I can't retrieve this parameters, please help me and try to find "main" bug in this code.
    try {
    URL url = new URL("http://localhost/index.jsp");
    HttpURLConnection httpCon = (HttpURLConnection)url.openConnection();
    httpCon.setRequestMethod( "POST" );
    httpCon.setDoOutput( true );
    String body = URLEncoder.encode("name=Oleg", "UTF-8");
    httpCon.setRequestProperty( "Content-length", Integer.toString( outBody.length() ));
    httpCon.setRequestProperty( "Content-type", "application/x-www-form-urlencoded" );
    OutputStream os = httpCon.getOutputStream();
    PrintWriter ow = new PrintWriter( os );
    ow.print( body );
    ow.flush();
    ow.close();
    } catch (....) {
    }

    Hi
    You must not encode all the body just the values of the parameters.
    You can do as following in order to send a post request with 2 parameters
    String param1 = "Co & sons";
    String param2 = "ltd.";
    String encParam1 = URLEncoder.encode(param1,"UTF-8");
    String encParam2 = URLEncoder.encode(param2,"UTF-8");
    String body = "param1="+encParam1+"&param2="+encParam2;
    OutputStream os = httpCon.getOutputStream();
    PrintWriter ow = new PrintWriter( os );
    ow.print( body );
    ow.flush();
    //read the response from the jsp
    InputStream inS = httpCon.getInputStream();
    byte[] buff = new byte[5000];
    StringBuffer sbuff = new StringBuffer();
    int nrBytes ;
    while( (nrBytes = inS.read(buff, 0, 5000))!=-1) {
      sbuff.append(new String(buff,0,nrBytes));
    inS.close();
    ow.close();
    ...This is the jsp page which gets the parameters
    <%
         String param1 = request.getParameter("param1");
         param1 = new String(param1.getBytes(),"utf-8");
         String param2 = request.getParameter("param2");
         param2 = new String(param2.getBytes(),"utf-8");
    %>I hope I helped you.
    Regards,
    BG

  • What's wrong with this code (AS3)?

    I want to publish a live stream and, when a button is pressed, publish the same stream for vod.  I haven't been able to get an answer as to whether I can do this...my code is below.  Can someone please tell me if I can do this, or what may be wrong with my code?
    The live stream and playback works fine; but the recording doesn't start.  Also, I want other objects on the client, such as the current camera and audio information, and the aspect ratio being used.  I havent' been able to get these to show up (i.e., the incomingLbl and outgoingLbl do not show up).
    Thank you,
    Phillip A
    My code:
    package {
        import flash.display.MovieClip;
        import flash.net.NetConnection;
        import flash.events.NetStatusEvent; 
        import flash.events.MouseEvent;
        import flash.events.AsyncErrorEvent;
        import flash.net.NetStream;
        import flash.media.Video;
        import flash.media.Camera;
        import flash.media.Microphone;
        import fl.controls.Button;
        import fl.controls.Label;
        import fl.controls.TextArea;
        import fl.controls.CheckBox;
        public class vodcast1 extends MovieClip {
            private var nc:NetConnection;
            private var nc2:NetConnection;
            private var ns:NetStream;
            private var ns2:NetStream;
            private var nsPlayer:NetStream;
            private var vid:Video;
            private var vidPlayer:Video;
            private var cam:Camera;
            private var mic:Microphone;
            private var camr:Camera;
            private var micr:Microphone;
            private var clearBtn:Button;
            private var startRecordBtn:Button;
            private var outgoingLbl:Label;
            private var incomingLbl:Label;
            private var myMetadata:Object;
            private var outputWindow:TextArea;
            private var cb1:CheckBox;
            public function vodcast1(){
                setupUI();
                nc = new NetConnection();
                nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                nc.connect("rtmp://localhost/publishLive");
                nc2 = new NetConnection();
                nc2.connect("rtmp://localhost/vod/videos");
                nc2.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus2);
            private function startRecordHandler(event:MouseEvent):void {
                publishRecordStream();
            private function onNetStatus(event:NetStatusEvent):void {
                trace(event.target + ": " + event.info.code);
                switch (event.info.code)
                    case "NetConnection.Connect.Success":
                        trace("Congratulations! you're connected to live");
                        publishCamera();
                        displayPublishingVideo();
                        displayPlaybackVideo();
                        break;
                    case "NetStream.Publish.Start":
            // NetStatus handler for Record stream       
            private function onNetStatus2(event:NetStatusEvent):void {
                trace(event.target + ": " + event.info.code);
                switch (event.info.code)
                    case "NetConnection.Connect.Success":
                        trace("Congratulations! you're connected to vod");                   
                        break;
                    case "NetConnection.Connect.Rejected":
                    case "NetConnection.Connect.Failed":
                    trace ("Oops! the connection was rejected");
                        break;
                    case "NetStream.Publish.Start":
                        sendMetadata();
                        break;
            private function asyncErrorHandler(event:AsyncErrorEvent):void {
                trace(event.text);
            private function sendMetadata():void {
                trace("sendMetaData() called")
                myMetadata = new Object();
                myMetadata.customProp = "Recording in progress";
                ns.send("@setDataFrame", "onMetaData", myMetadata);
            private function publishRecordStream():void {
                camr = Camera.getCamera();
                micr = Microphone.getMicrophone();
                ns2 = new NetStream(nc2);
                ns2.client = new Object();
                ns2.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus2);
                ns2.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                ns2.attachCamera(camr);
                ns2.attachAudio(micr);
                ns2.publish("vodstream", "record");           
            private function publishCamera():void {
                cam = Camera.getCamera();
                mic = Microphone.getMicrophone();
                ns = new NetStream(nc);
                ns.client = this;
                ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                ns.attachCamera(cam);
                ns.attachAudio(mic);
                ns.publish("livestream", "live");
            private function displayPublishingVideo():void {
                vid = new Video(cam.width, cam.height);
                vid.x = 10;
                vid.y = 30;
                vid.attachCamera(cam);
                addChild(vid); 
            private function displayPlaybackVideo():void {
                nsPlayer = new NetStream(nc);
                nsPlayer.client = this;
                nsPlayer.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                nsPlayer.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                nsPlayer.play("livestream");
                vidPlayer = new Video(cam.width, cam.height);
                vidPlayer.x = cam.width + 100;
                vidPlayer.y = 30;
                vidPlayer.attachNetStream(nsPlayer);
                addChild(vidPlayer);
            private function setupUI():void {
                outputWindow = new TextArea();
                outputWindow.move(250, 175);
                outputWindow.width = 200;
                outputWindow.height = 50;
                outgoingLbl = new Label();
                incomingLbl = new Label();
                outgoingLbl.width = 100;
                incomingLbl.width = 100;
                outgoingLbl.text = "Publishing Stream";
                incomingLbl.text = "Playback Stream";
                outgoingLbl.move(20, 200);
                incomingLbl.move(300, 200);
                outgoingLbl.condenseWhite = true;
                incomingLbl.condenseWhite = true;
                startRecordBtn = new Button();
                startRecordBtn.width = 150;
                startRecordBtn.move(250, 345);
                startRecordBtn.label = "Start Recording";
                startRecordBtn.addEventListener(MouseEvent.CLICK, startRecordHandler);
                //cb1 = new CheckBox();
                //cb1.label = "Record";
                //cb1.move(135,300);
                //cb1.addEventListener(MouseEvent.CLICK,publishRecordStream);
                //clearBtn = new Button();
    //            clearBtn.width = 100;
    //            clearBtn.move(135,345);
    //            clearBtn.label = "Clear Metadata";
    //            clearBtn.addEventListener(MouseEvent.CLICK, clearHandler);
                addChild(outgoingLbl);
                addChild(incomingLbl);
    //            addChild(clearBtn);
                addChild(startRecordBtn);
    //            addChild(cb1);
                addChild(outputWindow);
            public function onMetaData(info:Object):void {
                outputWindow.appendText(info.customProp);

    use event.currentTarget (and you don't need to repeatedly define the same function):
    var c:int;
    var buttonName:String;
    for (c = 1;c < 5;c++) {
         buttonNum = "button"+c;
         this[buttonNum].addEventListener(MouseEvent.MOUSE_DOWN, pressStepButton);
    function pressStepButton(event:MouseEvent) {          trace(event.currentTarget,event.currentTarget.name);     }

  • Crop Functio... what is wrong with this code???

    Hi all,
    I have created this method to crop my bufferedimage, but when i call it it does not seem to do anything. :(
    Can anyone see what is wrong with it please?
    Thank you for you help!
    Claire
    x
         public BufferedImage cropImage()
              mBufferedImageCrop = copy(mBufferedImage);
              Graphics grphc = mBufferedImageCrop.getGraphics();
              Rectangle desiredArea = new Rectangle(10,10,10,10);
              BufferedImage sub_bi = mBufferedImageCrop.getSubimage(desiredArea.x, desiredArea.y,
                                                                                 desiredArea.width, desiredArea.height);
              grphc = mBufferedImageCrop.getGraphics();
              grphc.drawImage(sub_bi, desiredArea.x, desiredArea.y, this);
              repaint();
              return sub_bi;
         }I call this method using:
    displayPanel.cropImage();
    displayPanel.validate();
    repaint();Thanx

    I worked out the problem!
    :)

  • What is wrong with this code; i just dot understand , please help

    <html>
    <head>
    <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
    <META HTTP-EQUIV="PRAGMAS" CONTENT="NO-CACHE">
    <META HTTP-EQUIV="EXPIRES" CONTENT="0">
    </head>
    <%@ page language="java" contentType="text/html" %>
    <%-- Import the necessary Java classes --%>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.servlet.http.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.awt.*" %>
    <%@ page import="java.net.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="java.util.*" %>
    <%
         String queryText = "insert into User values('";
              queryText = queryText.concat((String)request.getParameter("title"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("firstname"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("surname"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("email1"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("password2"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("security_question"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("security_answer"));
              queryText = queryText.concat("')");
         Statement stmt = null;
        ResultSet rs = null;
         try     {
                   //load the ODBC JDBC driver
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   //open a connection to the "gugis" database
                   Connection con = DriverManager.getConnection("jdbc:odbc:gugis","","");
                   //create a statement object for sending SQL queries
                   stmt = con.createStatement();
                   // Insert data into table using staement's method
                rs = stmt.executeQuery(queryText);          
                   //clean up all objects
                   stmt.close();
                   con.close();
                   response.sendRedirect("Reg_Success.html");
              catch (ClassNotFoundException err)
                   out.println("Data can't be inserted into our database...");
                   response.sendRedirect("Error.jsp");
    %>
    </html>error msg comes when i try to submit
    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: An exception occurred processing JSP page /gugis.co.uk/adduser.jsp at line 49
    46:                stmt = con.createStatement();
    47:                               
    48:                // Insert data into table using staement's method
    49:             rs = stmt.executeQuery(queryText);          
    50:
    51:                //clean up all objects
    52:                stmt.close();
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Number of query values and destination fields are not the same.
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
         org.apache.jsp.gugis_co_uk.adduser_jsp._jspService(adduser_jsp.java:130)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Number of query values and destination fields are not the same.
         sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
         sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
         sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110)
         sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
         sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)
         org.apache.jsp.gugis_co_uk.adduser_jsp._jspService(adduser_jsp.java:108)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
         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.16 logs.
    Apache Tomcat/6.0.16i am working on this for the last three hour but no luck
    please help
    Regards
    Gugi

    String queryText = "insert into User (Title, First_Name, Surname, Email, Password, Security_Question, Security_Answer) values('";
              queryText = queryText.concat((String)request.getParameter("title"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("firstname"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("surname"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("email1"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("password2"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("security_question"));
              queryText = queryText.concat("','");
              queryText = queryText.concat(request.getParameter("security_answer"));
              queryText = queryText.concat("')");i m using the above code instead of the other sql
    now i m getting the following
    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: javax.servlet.ServletException: java.sql.SQLException: No ResultSet was produced
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    javax.servlet.ServletException: java.sql.SQLException: No ResultSet was produced
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
         org.apache.jsp.gugis_co_uk.adduser_jsp._jspService(adduser_jsp.java:145)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    java.sql.SQLException: No ResultSet was produced
         sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:259)
         org.apache.jsp.gugis_co_uk.adduser_jsp._jspService(adduser_jsp.java:108)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
         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.16 logs.
    Apache Tomcat/6.0.16help plz
    regards
    gugi

  • What's wrong with my code? Help

    I'm attaching the code here in case it'd help in getting a faster response. This is supposed to be an exercise in turtle graphics. The idea is to use the program to draw shapes using a series of commands (I'm sure the experts here are familiar with it). It compiles and runs fine, however whenever certain commands are entered, after the move command, the program gives an exception "Array is out of bounds".
    For instance, if I enter
    1)2, 5, 1(step), 5, 1( step)
    and the print result it also not working.
    I'm a newbie to this, and I'm just trying to learn. Please help!
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.text.*;
    public class Turtle extends JApplet implements ActionListener
    JLabel commandLabel;
    JTextField command;
    JTextArea outputArea, array_area;
    char floor[][];
    int direction=0;
    String output="", number="";
    int i,j,n,com=0;
    int num=0,direct=0,pen_status=0;
    public void init()
    Container c= getContentPane();
    c.setLayout(new FlowLayout());
    outputArea = new JTextArea(9,15 );
    outputArea.setText("command"+"\n"+"1:pen up"+"\t"+"2:pen down"+"\n"+ "3:turn right"+"\t"+"4:turn left"+"\n"+ "5:move"+"\n"+"6:print"+"\n"+"9:end data");
    c.add(outputArea);
    commandLabel=new JLabel("Enter the command");
    c.add(commandLabel);
    command=new JTextField(8);
    command.addActionListener(this);
    c.add(command);
    floor=new char[20][20];
    for(int i=0;i<20;i++){
    for(int j=0;j<20;j++) {
    floor[i][j]='0';
    output+=floor[i][j];
    output+="\n";
    i=j=0;
    array_area = new JTextArea(20,20);
    c.add(array_area);
    array_area.setText(output);
         public void actionPerformed(ActionEvent e)
              play();
         public void play(){
    com = Integer.parseInt(command.getText());
    switch (com){
    case 1:
    showStatus("Pen is up");
    pen_status=0;
         command.setText("");
         break;
    case 2:
    showStatus("Pen is down");
    pen_status=1;
    command.setText("");
         break;
    case 3:
    showStatus("Turn right");
    direction+=90;
    command.setText("");
         break;
    case 4:
    showStatus("Turn left");
    direction-=90;
    command.setText("");
         break;
    case 5:
    number=JOptionPane.showInputDialog("Enter a number");
    num=Integer.parseInt(number);
    showStatus("moving");
    move();
    command.setText("");
         break;
    case 6:
    showStatus("print");
         print();
         command.setText("");
         break;          
    case 9:
         command.setEditable(false);
         break;
         default:
         showStatus("Entered the Wrong command");
    command.setText("");
         break;
         public void move()
         if (pen_status==0){
         direct = direction%360;
         switch(direct){
         case 90:
         for(n=1;n<=num;n++)
         j++;
         break;
    case 180:
    for(n=1;n<=num;n++)
         i++;
         break;
    case 270:
    for(n=1;n<=num;n++)
         j--;
         break;
    case 0:
    for(n=1;n<=num;n++)
         i--;
         break;
    else if(pen_status==1){
         direct = direction%360;
         switch(direct){
         case 90:
    for(n=1;n<=num;n++)
         floor[i][j++]='1';          
         break;
    case 180:
         for(n=1;n<=num;n++)
    floor[i++][j]='1';
         break;
    case 270:
         for(n=1;n<=num;n++)
    floor[i][j--]='1';
         break;
    case 0:
         for(n=1;n<=num;n++)
    floor[i--][j]='1';
         break;
         public void print()
         int a, b;
         output="";
         for(a=0;a<20;a++){
         for(b=0;b<20;b++){
         if(floor[a]=='1') {
         output+="*";
         else
         output+=" ";
         output+="\n";
         array_area.setText(output);     

    Ok, I wasn't aware of the code tags..
    Here're the errors I'm getting when I run the move command:
    java.lang.ArrayIndexOutOfBoundsException: -5
            at Turtle.move(Turtle.java:126)
            at Turtle.play(Turtle.java:80)
            at Turtle.actionPerformed(Turtle.java:51)
            at javax.swing.JTextField.fireActionPerformed(JTextField.java:489)
            at javax.swing.JTextField.postActionEvent(JTextField.java:670)
            at javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:7
    84)Can anyone help? I'm out of ideas and frustrated

  • What is wrong with this? pls help!

    I have this as a listener for a JButton:
         public void actionPerformed(ActionEvent e){
              try{
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   String url = "jdbc:odbc:RezSystem";
                   Connection con = DriverManager.getConnection(url, "user10", "");
                   PreparedStatement stmt = con.prepareStatement("select cPassword from RezShopper where cShopperID = ?");
                   stmt.setString(1, textSignInName.getText());
                   ResultSet res = stmt.executeQuery();
                   if(res.next()){
                        String tp = String.valueOf(passPassword.getPassword());
                        String dp = res.getString(1);
                        System.out.println("text field = " + tp);
                        System.out.println("database = " + dp);
                        if (dp.equals((String)dp)){
                             System.out.println("Password accepted");
                        else{
                             System.out.println("Invalid password");
                   else{
                        System.out.println("Invalid sign in name");
              catch(Exception ex){
                   System.out.println(ex);
         }this is used to compare the value in a password field and a value in a column in an sql data base with a char data type and should check if they are the same. The problem is that even if they are the same it still prints out "Invalid password". What went wrong???
    thanks

    dp.equals(dp) should give you true, but I guess you meant dp.equals(tp). To debug it, I would print the character values of both strings. You don't need to cast the String to a String before you call equals..
    for (int x = 0; x < dp.length(); x++)
      System.out.println("dp("+x+")="+(int)dp.charAt(x));
    for (int x = 0; x < tp.length(); x++)
      System.out.println("tp("+x+")="+(int)tp.charAt(x));I assume that getPassword returns a char array and not a byte array. If it returns a byte array, it is possible that the charset encoding gives you a different string than you expected.

  • What's wrong with this query--need help

    Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
    select ename
    from emp
    where to_char(hiredate,'day')='tuesday';
    when i execute the query
    o/p is no rows selected
    please help.
    thanks in advance.

    Hi,
    861173 wrote:
    Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
    select ename
    from emp
    where to_char(hiredate,'day')='tuesday';
    when i execute the query
    o/p is no rows selected Try:
    WHERE   TO_CHAR (hiredate, 'fmday')  = 'tuesday'Without 'FM" in the 2nd argument, TO_CHAR pads the results to make it a consistent length. If your NLS_DATE_LANGUAGE=ENGLISH, that means it will always return a 9-character string, since the longest name in English ('Wednesday') has 9 letters. 'FM' (case-insernsitive) tells TO_CHAR not to add that kind of padding.

  • Connected to Internet or not connected? what is wrong with this code?

    hi
    here is a simple code to check whether Internet is connected to my machine or not----------
    import java.net.*;
    class CheckNet
         public static void main(String args[])
              while(true)
                   check();
                   try{
                   Thread.sleep(1000);
                   }catch(InterruptedException ie){System.out.println(ie);}
         static void check()
              try
                             String hostAddress ;
                             InetAddress localHost ;
                                  localHost = InetAddress.getLocalHost();
                                  hostAddress = localHost.getHostAddress();
                                  if (hostAddress.equals( "127.0.0.1" ))
                                  System.out.println("Not connected");
                                  else
                                  System.out.println("Connect to host: " + hostAddress);
                        catch(UnknownHostException ukhe){System.out.println(ukhe);}
    this code tells the status of connection at first call of method check() in code, but can not update itself i.e if status of net conn is changed prog continues to output the same result.
    CAN ANYBODY HELP ME TO REMOVE THE BUG / or suggest a better way?
    regards

    I've run into the same issue and found the following:
    InetAddress caches successful and unsuccessful host name resolutions (See JavaDocs for InetAddress for more detail on this).
    My guess is that InetAddress has cached the unsuccessful attempt and therefore when a network connection is established in your application loop, InetAddress "thinks" its still not connected.
    The JavaDocs say something about setting a security property which can control the cache time, but I haven't been able to get InetAddress to recognize the property change. I'm probably not setting it in the right place.
    HTH,
    robert

  • Empty field Validation before Print, What's Wrong with THIS code??

    I have been trying unsuccessfully to get this code to work.. I am stumped!  I created a print button.  Then added this script under "Form Calc" in the Click event of the button.  But when clicked nothing happens.  I have a radio button group that has different options but I only want to make the field NameofReferralSource required if the user checks Broker.  The print button is on page 1.  The field and radio button group are on page 7.  I just can't figure out how to get this to work.  I don't necessarily need to make the fields required since then I would have to add script remove the red border and add a message telling user where the field is otherwise they will have to search through 6 pages to find it. (maybe a better solution?)  I just want a simple code that fires when the user hits the Print, Save, or Submit button to check if Broker name is empty and if it is, prompt them to fill in.  Help!
    if ((topmostSubform.Page7.NameofReferralSource.rawValue == null)  & (topmostSubform.Page7.Howdidyouhear.0.rawValue == "Broker")) then
    xfa.host.messageBox("You must enter the the Name of the Broker under Referral Name on Page 7 to be able to print this form")
    else
    Print_Form.execEvent("click")
    endif
    Brenda

    Ok, well my reference to the fields were incorrect.  Here is the new code:
    if (Page7.NameofReferralSource.rawValue == null){
    xfa.host.messageBox("You must enter the the Name of your Referral on the bottom of Page 7 to be able to print this form");
    }else{
    Print_Form.execEvent("click");
    xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);
    The first part that checks for an empty field and displays a message works however the print dialog still pops up after the user clicks ok to the error message.  Any ideas?

  • What's wrong with this code. Any Help please?

    Hello
    I'm a newbie to java programming.I got this sample code from an online book that I use in learning java and I'm trying to run the code on eclipse but I got this error message
    "Fatal exception occurred. Programm will exit."
    This is the code:
    public class MostDivisors {
         public static void main(String[] args) {
              int N;
              int maxDivisors;
              int numWithMax;
              maxDivisors = 1;
              numWithMax = 1;
              for(N = 2 ; N <= 10000 ; N++){
                   int D;
                   int divisorCount;
                   divisorCount = 0;
                   for(D=0; D <= N; D++){
                        if (N % D == 0)
                             divisorCount++;
                   if (divisorCount > maxDivisors){
                        maxDivisors = divisorCount;
                        numWithMax = N;
              System.out.println("Among intergers between 1 and 10000,");
              System.out.println("The maximum number of divisors is "+maxDivisors);
              System.out.println("A number with " + maxDivisors + " divisors is ");
    Any Help will be appreciated. Thank you all for helping me out understand the problem here

    Thank you all participating to help this out.
    This is the code and the detailed error message:
    public class MostDivisors {
         public static void main(String[] args) {
              int N;
              int maxDivisors;
              int numWithMax;
              maxDivisors = 1;
              numWithMax = 1;
              for(N = 2 ; N <= 10000 ; N++){
                   int D;
                   int divisorCount;
                   divisorCount = 0;
                   for(D=0; D <= N; D++){
                        if (N % D == 0)
                             divisorCount++;
                   if (divisorCount > maxDivisors){
                        maxDivisors = divisorCount;
                        numWithMax = N;
              System.out.println("Among intergers between 1 and 10000,");
              System.out.println("The maximum number of divisors is "+maxDivisors);
              System.out.println("A number with " + maxDivisors + " divisors is ");
    ERROR MESSAGE starts HERE:
    java.lang.ArithmeticException: / by zero
         at MostDivisors.main(MostDivisors.java:30)
    Exception in thread "main"
    I do not think this is related to the JVM because other programs will compile and run successfully.
    Any Help will be appreciated. Thanks

Maybe you are looking for

  • Smartcardio ResponseAPDU buffer size issue?

    Greetings All, I’ve been using the javax.smartcardio API to interface with smart cards for around a year now but I’ve recently come across an issue that may be beyond me. My issue is that I whenever I’m trying to extract a large data object from a sm

  • NoMatchingActionMethodException error when extending class

    I have a base class (BaseProcess) that extends the PageFlowController. This class has an instance of a form: ,FSFormBean. I also have an action method that uses this form: * @jpf:action * @jpf:forward name="success" path="../hub/HubController.jpf" pu

  • BI install problem

    anytime i try to install oracle BI Suite it gives me this error:cannot write into c:/windows/system32/mfcans32.dll what can i do to resolve this issue Kindly help

  • Issues with ingesting MiniDV tapes in synch

    I am currently ingesting a ton of MiniDV tapes for a project but keep having synch issues. Image and sound will be in synch for the initial portion of a clip, but will eventually fall out of synch. Any ideas as to how to fix this problem? I'm working

  • Unsure what to do with my broken 80gb classic.

    I have just received a 80gb classic as a gift from my work, it arrived tuesday and was working fine, i updated it to the latest firmware and loaded all my podcasts and music on and its been great since. Today i dropped it. straight vertical fall onto