"AssignmentOperator ArrayInitializer" to complete ForInit - JSP

The following JSP page produced an error when I tried to access it thru an html form.
I am running Tomcat as my servlet engine\ web server.
err msg:
Generated servlet error:
Syntax error, insert "AssignmentOperator ArrayInitializer" to complete ForInit
from the following code:
<%@ page import="java.sql.*" language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<jsp:useBean id="emp" class="company.beans.EmployeeBean" scope="session">
<jsp:setProperty name="emp" property="lastname"/>
</jsp:useBean>
<body>
<%
company.util.DBConnect dbcon = new company.util.DBConnect();  //DBConnect class for connection to mySQL
java.util.ArrayList al = dbcon.getEmployee(emp); //retrieve ArrayList of Employees with queried lastname
int counter = 0;
for (counter ; counter<al.size(); counter ++){
     out.println(al[counter].getEmployeeID());
     out.println(al[counter].getFirstNmae());
     out.println(al[counter].getLastName());
     out.println(al[counter].getRole());
%>
</body>
</html>I can't figure out what went wrong.

Syntax error, insert "AssignmentOperator ArrayInitializer" to complete ForInitYou have a syntax error. You must insert an Assignment Operator or Array Initializer to complete the For loop initialization.
A for loop definition must contain 3 parts
for([initialization] ; [loop continuation condition] ; [increment action])
You are using
for( counter ; counter < al.size() ; counter ++)
Which contains
for( [variable reference] ; [loop continuation condition] ; [increment action])
Can you tell how to fix the problem now?
Well, the real fix to not use scriptlets. The code I would use would look something like this:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<jsp:useBean id="emp" class="company.beans.EmployeeBean" scope="session">
    <jsp:setProperty name="emp" property="lastname"/>
</jsp:useBean>
<jsp:useBean id="dbConnector" class="company.util.DBConnect(); scope="page">
    <jsp:setProperty name="dbConnector" property="employeeLastName" value="${emp}"/>
    <c:set var="employees" value="${dbConnector.employee}"/>
</jsp:useBean>
<body>
    <c:forEach var="employee" items="employees">
        <c:out value="${employee.employeeID}"/><br/>
        <c:out value="${employee.firstName}"/><br/>
        <c:out value="${employee.lastName}"/><br/>
        <c:out value="${employee.role}"/><br/>
    </c:forEach>
</body>
</html>
{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • "Syntax error, insert "AssignmentOperator Expression" to complete ForInit"?

    I am getting this unknown error and do not know how to solve it.
    here is my code:
    it gives me the error for the first part of both for loops.
    int THISHOLDSTHEVALUEOFTHENUMBEROFTIMESTOLOOPINTHEFIRSTLOOP = 3;
              int THISHOLDSTHEVALUEOFTHENUMBEROFTIMESTOLOOPINTHESECONDLOOP = 3;
              int THISHOLDSTHECOUNTERVALUEFORTHEFIRSTLOOP = 0;
              int THISHOLDSTHECOUNTERVALUEFORTHESECONDLOOP = 0;
              int THISHOLDSTHEVALUECALCULATEDTHOUGHTHEFIRSTANDSECONDLOOP = 3;
              for(THISHOLDSTHECOUNTERVALUEFORTHEFIRSTLOOP;
                   THISHOLDSTHECOUNTERVALUEFORTHEFIRSTLOOP <= THISHOLDSTHEVALUEOFTHENUMBEROFTIMESTOLOOPINTHEFIRSTLOOP;
                        THISHOLDSTHECOUNTERVALUEFORTHEFIRSTLOOP++)
                   for(THISHOLDSTHECOUNTERVALUEFORTHESECONDLOOP;
                        THISHOLDSTHECOUNTERVALUEFORTHESECONDLOOP <= THISHOLDSTHEVALUEOFTHENUMBEROFTIMESTOLOOPINTHESECONDLOOP;
                             THISHOLDSTHECOUNTERVALUEFORTHESECONDLOOP++)
                        THISHOLDSTHEVALUECALCULATEDTHOUGHTHEFIRSTANDSECONDLOOP *= THISHOLDSTHEVALUECALCULATEDTHOUGHTHEFIRSTANDSECONDLOOP;
              }

    JacobsB wrote:
    it has to be like this
    int THISHOLDSTHEVALUEOFTHENUMBEROFTIMESTOLOOPINTHEFIRSTLOOP = 3;
              int THISHOLDSTHEVALUEOFTHENUMBEROFTIMESTOLOOPINTHESECONDLOOP = 3;
              int THISHOLDSTHECOUNTERVALUEFORTHEFIRSTLOOP;
              int THISHOLDSTHECOUNTERVALUEFORTHESECONDLOOP;
              int THISHOLDSTHEVALUECALCULATEDTHOUGHTHEFIRSTANDSECONDLOOP = 3;
              for(THISHOLDSTHECOUNTERVALUEFORTHEFIRSTLOOP = 0;
                   THISHOLDSTHECOUNTERVALUEFORTHEFIRSTLOOP <= THISHOLDSTHEVALUEOFTHENUMBEROFTIMESTOLOOPINTHEFIRSTLOOP;
                        THISHOLDSTHECOUNTERVALUEFORTHEFIRSTLOOP++)
                   for(THISHOLDSTHECOUNTERVALUEFORTHESECONDLOOP = 0;
                        THISHOLDSTHECOUNTERVALUEFORTHESECONDLOOP <= THISHOLDSTHEVALUEOFTHENUMBEROFTIMESTOLOOPINTHESECONDLOOP;
                             THISHOLDSTHECOUNTERVALUEFORTHESECONDLOOP++)
                        THISHOLDSTHEVALUECALCULATEDTHOUGHTHEFIRSTANDSECONDLOOP *= THISHOLDSTHEVALUECALCULATEDTHOUGHTHEFIRSTANDSECONDLOOP;
    Thanks JacobsB.

  • [help!] Syntax error, insert "AssignmentOperator ArrayInitializer"...

    <%
      String USERNAME = (String)session.getAttribute("USERNAME");
        String myBlogUrl;
         if (USERNAME==null){                    
                  session.setAttribute("loginStatus","Not Logged In");//status: user NOT logged in              
                  myBlogUrl = "loginFail.jsp";
           esle {
                 myBlogUrl = "blog.jsp?username="+USERNAME;
        %>
        <ul>
          <li><a href="<%=myBlogUrl%>">My Blog</a></li>
    ...(navbar.jsp)
    1. I include masthead.jsp and navbar.jsp in a few other .jsp files using:
    <%@ include file="include/navbar.jsp" %>2. USERNAME is also declared in masthead.jsp:
    String USERNAME = (String)session.getAttribute("USERNAME");
    Tomcat gives an exception message as follows:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 11 in the jsp file: /include/navbar.jsp
    Generated servlet error:
    Syntax error, insert ";" to complete Statement
    An error occurred at line: 11 in the jsp file: /include/navbar.jsp
    Generated servlet error:
    Syntax error, insert[b] "AssignmentOperator ArrayInitializer" to complete ArrayInitializerAssignement
    3. I guesses there might be the problem with String USERNAME = (String)session.getAttribute("USERNAME");, so I deleted from navbar.jsp, but the problem still exists.
    So, this means there is some syntax problem with the statements in navbar.jsp? how can I solve the problem?

    Can't see anything wrong in the code you have posted.
    Error: AssignmentOperator ArrayInitializer
    The error message would lead me to look for any arrays you are declaring in your code. Are you declaring an array? Are you trying to initialize it? Have you closed all quotes/brackets etc etc?

  • AssignmentOperator ArrayInitializer error

    please help me
    <%@ page language="java" import="com.emb.ongopim.handler.*, com.emb.ongopim.beans.*, java.util.*" session="true"%>
    <jsp:useBean id="calInfo" scope="request" class="com.emb.ongopim.handler.CalendarHandler"/>
    <jsp:setProperty name="calInfo" property="*"/>
    <%
              CalendarInfo ci=new CalendarInfo();
              ci.setStart_date(request.getParameter("meetingStartdate"));
              ci.setStart_time(request.getParameter("meetingStarttime"));
              ci.setMet_end_date(request.getParameter("meetingEnddate"));
              ci.setMet_end_time(request.getParameter("meetingEndtime"));
              ci.setAlert_date(request.getParameter("meetingAlertdate"));
              ci.setAlert_time(request.getParameter("meetingAlerttime"));
              ci.setMet_location(request.getParameter("meetingLocation"));
              ci.setSubject(request.getParameter("meetingSubject"));
              int errcode=ci.validateInput(MEET);
              if(errcode==100)
              calInfo.addMeeting(ci);
              else
              String errmsg=eh.getErrorMessage(errCode);
    %>
    this is my jsp code and after running in tomcat i am getting "AssignmentOperator ArrayInitializer" to complete ArrayInitializerAssignment.. any one help me sort out this problem
    Message was edited by:
    rakesh.pachava

    Hi,
    Post the exception message you are getting.
    And please use the code button, code tags to show your code sample, it becomes easier to read the code.

  • Syntax Error - AssignmentOperator ArrayInitializer

    Hi All,
    For the following statement -
    (m_querySection.isExpanded()?(m_sashWeights[0] = 15) : (m_sashWeights[0] = 20));I am getting the error - Syntax error, insert "AssignmentOperator ArrayInitializer" to complete Expression
    The return type for the method isExpanded() is boolean.
    Please suggest me where am I going wrong?
    Thanks in advance.
    Regards,
    Ashish A.

    That construct is supposed to be an expression, not a statement. Perhaps you meant(m_querySection.isExpanded()?(m_sashWeights[0] == 15) : (m_sashWeights[0] == 20));but I suspect not as you aren't assigning the result to anything. If you are really in love with that ternary operator then you could save it by doing this:m_sashWeights[0] = (m_querySection.isExpanded() ? 15 : 20);

  • Syntax error, insert "AssignmentOperator Expression" to complete Expression

    Hi experts,
    I am very new in Java. Currently, I get stuck in the exception of program. Please help me figure out what is the issue. The eclipse raises the error "Syntax error, insert "AssignmentOperator Expression" to complete Expression" at the command "exception;" as below code.
    Thanks,
    Hieu
    Edited by: user122479 on Apr 5, 2013 4:23 PM

    user122479 wrote:
    I put { code } as your advice, but it is still error.You put the tage in your *.java file?
    Oh dear!
    I think you should  take a few days to go trough the Java tutorials
    http://docs.oracle.com/javase/tutorial/ starting at "Trails Covering the Basics"
    Then you should find a tutorial on your IDE to learn how to import a project.
    Programming is a craft.
    And as with any craft you need some knowledge on your matter and training on your tools.
    A forum is not the right place to gather either one.
    bye
    TPD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problems with Complete Bi JSP Application.

    Hello.
    I can see perfectly my presentation, it connect with database perfectly, but when i creacte a complete bi Jsp Application to incorporate this Bi Bean Object , i have this problem.
    It generate a exception in MetadataManager and cannot connect with database.
    Could anybody help me?
    Thanks a lot.
    BIB-18007 Se ha producido una excepción de MetadataManager. BIB-10100 No se puede conectar a la base de datos. (Motivo: Consulte el error oracle.i1) BIB-16601 No se puede conectar a la base de datos. (Motivo: Consulte el error oracle.i1) oracle.i18n.util.builder.UnicodeMapChar oracle.i18n.util.builder.UnicodeMapChar
    Rastreo de pila
    javax.servlet.jsp.JspException: BIB-18007 Se ha producido una excepción de MetadataManager.
    BIB-10100 No se puede conectar a la base de datos. (Motivo: Consulte el error oracle.i1)
    BIB-16601 No se puede conectar a la base de datos. (Motivo: Consulte el error oracle.i1)
    oracle.i18n.util.builder.UnicodeMapChar
    oracle.i18n.util.builder.UnicodeMapChar
    at oracle.dss.addins.jspTags.PresentationTag.doStartTag(PresentationTag.java:293)
    at Analyze1.jspService(Analyze1.jsp:12)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:347)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
    at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:649)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
    at java.lang.Thread.run(Thread.java:534)

    This usually implies the JSP application cannot connect to the database listed in your runtime configuration setting of your BIDesigner.
    In the BIDesigner check to see how the runtime connection is configured. There are two options:
    a) Use design settings - this will use the local catalog in your JDev project
    b) you can create a specify a BIDesigner connection and a corresponding BI Catalog connection
    If you are using option (b) then make sure your presentation is copied to the BI Catalog. Then test all the connections including the catalog connection listed on the runtime settings tab of the BIDesigner.
    Hope this helps
    Business Intelligence Beans Product Management Team
    Oracle Corporation

  • Problems with writing to file, and with ActionListener.

    I have been trying to write a Payroll Division type program as my school Computer Science Project. However, I have a few problems with it...
    import java.io.IOException;
    import java.io.FileOutputStream;
    import java.io.FileInputStream;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.util.StringTokenizer;
    import javax.swing.*;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.*;
    public class Personnel implements ActionListener  {    
             JFrame GUIFrame;
             JLabel ID, Line, OKText,AnswerField;
             JTextField IDField, LineField;
             JButton OK;
             JPanel GUIPanel;
             int trialCounter=0;
             final static int employeeNumber = 7;
             final static int maxValue = ((employeeNumber*4)-1);
            //Number of employees, which would be in real life passed by the Payroll division.   
            public static String [][] sortHelp = new String [employeeNumber+1][3];    /** Creates a new instance of Personnel */       
            public Personnel() {
              GUIFrame = new JFrame("PersonnelSoft"); //create title header.
                     GUIFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                     GUIFrame.setSize(new Dimension(100, 140));
                     GUIPanel= new JPanel(new GridLayout(2, 2));
                     addWidgets();
                     GUIFrame.getRootPane().setDefaultButton(OK);
                     GUIFrame.getContentPane().add(GUIPanel, BorderLayout.CENTER);
                     GUIFrame.pack();
                    GUIFrame.getContentPane().setVisible(true);
                    GUIFrame.setVisible(true);
            private void addWidgets() {
                  ID = new JLabel ("Please enter your employee Identification Number:", SwingConstants.LEFT);
                  IDField = new JTextField ("ID", 5);
                  Line = new JLabel ("Please enter the line of your payroll with which you have concerns:", SwingConstants.LEFT);
                  LineField = new JTextField ("###", 2);
                  OKText = new JLabel ("Click OK when you have verified the validity of your request", SwingConstants.LEFT);
                  OK = new JButton ("OK");
                  OK.setVerticalTextPosition(AbstractButton.CENTER);
                  OK.setMnemonic(KeyEvent.VK_I);
                  AnswerField = new JLabel("The Result of your Querie will go here", SwingConstants.LEFT);
                  GUIPanel.add(ID);
                  GUIPanel.add(IDField);
                  GUIPanel.add(Line);
                  GUIPanel.add(LineField);
                  GUIPanel.add(OKText);
                  GUIPanel.add(OK);
                  GUIPanel.add(AnswerField);
                  OK.addActionListener(this);
                  ID.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
                  OKText.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
                  Line.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
            public static void ArrayCreate() throws IOException {   
              //creates a employeeNumber x 3 array, which will hold all data neccessary for future sorting by employee ID number.      
              int counter = 2;      
              int empCounter = 1;      
              String save;
              //avoid having to waste memory calculating this value every time the for loop begins 
              FileInputStream inFile = new FileInputStream("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR.txt"); 
              BufferedReader in = new BufferedReader(new InputStreamReader(inFile));
              String line;
                    line = in.readLine();
                    StringTokenizer st = new StringTokenizer(line);
                    save = st.nextToken();
                    sortHelp[0][0] = save;
                    sortHelp[0][2] = save;
                    while (st.hasMoreTokens()) {
                    save = st.nextToken();   
                    sortHelp[0][1] = save;
                    while (counter <= maxValue) {
                    line = in.readLine();
                    if (((counter - 1) % 4) == 0) {
                    st = new StringTokenizer(line);
                    sortHelp[empCounter][0] = st.nextToken();
                    sortHelp[empCounter][2] = sortHelp[empCounter][0];
                    while (st.hasMoreTokens()) {
                    save = st.nextToken();   
                    sortHelp[empCounter][1] = save;
                    empCounter++;
                    counter++;
                 public static String[] joinString() {
                      String[] tempStorage = new String[employeeNumber+1];
                      int counter;
                      for (counter = 0; counter <= employeeNumber; counter++) {
                           tempStorage[counter] = (sortHelp[counter][1] + sortHelp[counter][0]);
                      return (tempStorage);
                 public static String[] sortEm(String[] array, int len)
                     java.util.Arrays.sort(array);
                     return array;
                 public static void splitString(String[] splitString){
                    int counter;
                    for (counter = 0; counter <= employeeNumber; counter++){
                         sortHelp[counter][0]=splitString[counter].substring( 5 );
                         sortHelp[counter][1]=splitString[counter].substring(0,5);
                 void setLabel(String newText) {
                     AnswerField.setText(newText);
                 void writetoHR(String local) throws IOException {
                      FileOutputStream outFile = new FileOutputStream ("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR2.txt");
                       BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outFile));
                       out.write(local+"the preceding employee number is not in our database, but has submitted a request. Please sort out the issue");
                       System.exit(0);
                 public void actionPerformed(ActionEvent e){
                      boolean flag=false;
                      String local=IDField.getText();
                      int i=0;
                      while((i<=employeeNumber)&&(flag==false)){
                           if (sortHelp[1]==local) {
                   flag=true;
              i++;
         trialCounter++;
         if (trialCounter>=3)
              writetoHR(local);
         if (flag==false)
              setLabel("Your ID number does not exist in our records. Verify your ID and try again.");
         else {
              switch (LineField.getText())
              case 04:
                   setLabel("Your pay is calculated by multiplying your working hours by the amount per hour. If both of these fields are satisfactory to you, please contact humanresource");
                   break;
              case 03:
                   setLabel("Hourly amount was calculated by the system, by dividing your yearly pay 26 and then 80.");
                   break;
              case 07:
                   setLabel("Overtime pay was calculated by multiplying regular hourly pay by 1.1");
                   break;
              case 06:
                   setLabel("The overtime hourly pay was multiplied by the amount of overtime hours.");
                   break;
              case 10:
                   setLabel("For holiday hours, your pay is increased by 25%.");
                   break;
              case 09:
                   setLabel("The holiday hourly pay was multiplied by your amount of holiday hours.");
                   break;
              case 11:
                   setLabel("Your total pay was calculated by adding all the separate types of payment to your name.");
                   break;
              case 17:
                   setLabel("Your net pay was found by subtracting the amount withheld from your account");
                   break;
              case 19:
                   setLabel("Your sick hours remaining were taken from a pool of 96 hours.");
                   break;
              default:
                   setLabel("Please contact humanresource.");
              break;
    private static void CreateAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true);
    Personnel GUI = new Personnel();
         public static void main(String[] args) throws IOException {
              String[] temporary = new String[employeeNumber];
              ArrayCreate();
    temporary = joinString();
    temporary = sortEm(temporary, employeeNumber);
    splitString(temporary);
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    CreateAndShowGUI();
    int row;
    int column;
         for (row = 0; row < (employeeNumber); row++) {    // verify proper output by ArrayCreate splitString
    for (column = 0; column <= 2; column++) {
    System.out.print(sortHelp[row][column]);
    System.out.print(' ');
    System.out.print(' ');
    System.out.println();
    1) It does not permit me to switch on a String. How do I solve that?
    2)How would I throw an exception (IO) within actionperformed?
    3)Generally, if cut it down to everything except the writing to a file part, the actionperformed script causes an error... why?
    Thanks in advance.
    And sorry for the relative lameness of my question...
    ---abe---

    Thank you very much. That did solve almost all the problems that I had...
    I just have one more problem.
    First (here's the new code):
    import java.io.IOException;
    import java.io.FileOutputStream;
    import java.io.FileInputStream;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.util.StringTokenizer;
    import javax.swing.*;
    import java.util.*;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.*;
      public class Personnel implements ActionListener  {    
             JFrame GUIFrame;
              JLabel ID, Line, OKText,AnswerField;
               JTextField IDField, LineField;
               JButton OK;
               JPanel GUIPanel;
               int trialCounter=0;
         final static int employeeNumber = 7;
         final static int maxValue = ((employeeNumber*4)-1);
                public static String [][] sortHelp = new String [employeeNumber+1][3];   
         public Personnel() {
              GUIFrame = new JFrame("PersonnelSoft"); //create title header.
             GUIFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             GUIFrame.setSize(new Dimension(100, 140));
             GUIPanel= new JPanel(new GridLayout(2, 2));
             addWidgets();
             GUIFrame.getRootPane().setDefaultButton(OK);
             GUIFrame.getContentPane().add(GUIPanel, BorderLayout.CENTER);
             GUIFrame.pack();
            GUIFrame.getContentPane().setVisible(true);
            GUIFrame.setVisible(true);
            private void addWidgets() {
                  ID = new JLabel ("Please enter your employee Identification Number:", SwingConstants.LEFT);
                  IDField = new JTextField ("ID", 5);
                  Line = new JLabel ("Please enter the line of your payroll with which you have concerns:", SwingConstants.LEFT);
                  LineField = new JTextField ("###", 2);
                  OKText = new JLabel ("Click OK when you have verified the validity of your request", SwingConstants.LEFT);
                  OK = new JButton ("OK");
                  OK.setVerticalTextPosition(AbstractButton.CENTER);
                  OK.setMnemonic(KeyEvent.VK_I);
                  AnswerField = new JLabel("The Result of your Querie will go here", SwingConstants.LEFT);
                  GUIPanel.add(ID);
                  GUIPanel.add(IDField);
                  GUIPanel.add(Line);
                  GUIPanel.add(LineField);
                  GUIPanel.add(OKText);
                  GUIPanel.add(OK);
                  GUIPanel.add(AnswerField);
                  OK.addActionListener(this);
                  ID.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
                  OKText.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
                  Line.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
            public static void ArrayCreate() throws IOException {   
              int counter = 2;      
              int empCounter = 1;      
              String save;
              FileInputStream inFile = new FileInputStream("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR.txt"); 
              BufferedReader in = new BufferedReader(new InputStreamReader(inFile));
              String line;
                    line = in.readLine();
                    StringTokenizer st = new StringTokenizer(line);
                    save = st.nextToken();
                    sortHelp[0][0] = save;
                    sortHelp[0][2] = save;
                    while (st.hasMoreTokens()) {
                    save = st.nextToken();   
                    sortHelp[0][1] = save;
                    while (counter <= maxValue) {
                    line = in.readLine();
                    if (((counter - 1) % 4) == 0) {
                    st = new StringTokenizer(line);
                    sortHelp[empCounter][0] = st.nextToken();
                    sortHelp[empCounter][2] = sortHelp[empCounter][0];
                    while (st.hasMoreTokens()) {
                    save = st.nextToken();   
                    sortHelp[empCounter][1] = save;
                    empCounter++;
                    counter++;
                 public static String[] joinString() {
                      String[] tempStorage = new String[employeeNumber+1];
                      int counter;
                      for (counter = 0; counter <= employeeNumber; counter++) {
                           tempStorage[counter] = (sortHelp[counter][1] + sortHelp[counter][0]);
                      return (tempStorage);
                 public static String[] sortEm(String[] array, int len)
                     java.util.Arrays.sort(array);
                     return array;
                 public static void splitString(String[] splitString){
                    int counter;
                    for (counter = 0; counter <= employeeNumber; counter++){
                         sortHelp[counter][0]=splitString[counter].substring( 5 );
                         sortHelp[counter][1]=splitString[counter].substring(0,5);
                 void setLabel(String newText) {
                     AnswerField.setText(newText);
                 void writetoHR(String local) throws IOException {
                      FileOutputStream outFile = new FileOutputStream ("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR2.txt");
                       BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outFile));
                       out.write(local+"the preceding employee number is not in our database, but has submitted a request. Please sort out the issue");
                       System.exit(0);
                 public void actionPerformed(ActionEvent e){
                      boolean flag=false;
                      String local=IDField.getText();
                      local trim();
                      int i=0;
                      while((i<employeeNumber)&&(flag==false)){
                           if (sortHelp[1]==local) {
                   flag=true;
              else {
         i++;
         trialCounter++;
         if (trialCounter>=3)
              try {
                   writetoHR(local);
              } catch (IOException exception) {
    setLabel("We are sorry. The program has encountered an unexpected error and must now close");
              } finally {
         if (flag==false)
              setLabel("Your ID number does not exist in our records. Verify your ID and try again.");
         else {
              final Map m = new HashMap();
              m.put("04","Your pay is calculated by multiplying your working hours by the amount per hour. If both of these fields are satisfactory to you, please contact humanresource.");
              m.put("03", "Hourly amount was calculated by the system, by dividing your yearly pay 26 and then 80.");
              m.put("07", "Overtime pay was calculated by multiplying regular hourly pay by 1.1");
              m.put("06", "The overtime hourly pay was multiplied by the amount of overtime hours.");
              m.put("10", "For holiday hours, your pay is increased by 25%.");
              m.put("09", "The holiday hourly pay was multiplied by your amount of holiday hours.");
              m.put("11", "Your total pay was calculated by adding all the separate types of payment to your name.");
              m.put("17", "Your net pay was found by subtracting the amount withheld from your account.");
              m.put("19", "Your sick hours remaining were taken from a pool of 96 hours.");
    setLabel(m.get(LineField.getText()));
    private static void CreateAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true);
    Personnel GUI = new Personnel();
    public static void main(String[] args) throws IOException {
              String[] temporary = new String[employeeNumber];
              ArrayCreate();
    temporary = joinString();
    temporary = sortEm(temporary, employeeNumber);
    splitString(temporary);
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    CreateAndShowGUI();
    int row;
    int column;
         for (row = 0; row < (employeeNumber); row++) {    // verify proper output by ArrayCreate splitString
    for (column = 0; column <= 2; column++) {
    System.out.print(sortHelp[row][column]);
    System.out.print(' ');
    System.out.print(' ');
    System.out.println();
    Now that code above produces two errors. First of all.
    local trim();produces the error:
    Syntax error, insert "AssignmentOperator ArrayInitializer" to complete ArrayInitializerAssignementSecondly, if I take that into comments, the line
    setLabel(m.get(LineField.getText()));Produces the error:
    The method setLabel(String) in the type Personnel is not applicable for the arguments (Object)If anybody could help me solve these, I would be sincerely thankfull.
    Now, before anybody asks as to why I want to trim the String in the first place, it is due to the fact that I compare it to another String that is without whitespaces. Thus the field that DOES have whitespaces was preventing me from launching into the if loop:
    if (sortHelp[1]==local) {
                   flag=true;
    (within actionperformed) Or at least that's my explanation as to why the loop never launched. If it is wrong, can somebody please explain?)
    I apologize for the horrible indentation and lack of comments. This is an unfinished version.. I'll be adding the comments last (won't that be a joy), as well as looking for things to cut down on and make the program more efficient.
    Anyways,
    Thanks in Advance,
    ---abe---

  • Errors with a readFile method

    I wrote a method that is designed to read input from a file (readPlayers) and am getting two errors that I cannot figure out. Can you suggest why I'm getting these errors? The first error is on line 17 public void readPlayers( fin, teamArray) and reads:      Syntax error on token "(", = expected
         Syntax error on token ")", ; expected
    the second error is on line 53 else (type.equals("Hockey")) and reads Syntax error, insert ";" to complete Statement
         Syntax error, insert "AssignmentOperator ArrayInitializer" to complete ArrayInitializerAssignement
    Neither of these errors seem to fit so I'm wondering if the actual errors occur earlier in the code.??? Any help would be appreciated.
    import java.io.IOException;
    import java.util.*;
    public class TeamTwo
         private String city;
         //private String [] player;
         private static String cout;
         public static void main(String [] args) throws IOException
              Scanner fin = TFI.OpenInputFile();
              Scanner kb = new Scanner (System.in);
              int menuChoice = 0;
              public void readPlayers( fin, teamArray)
                  Player newPlayer = null;
                  int games = 0;               //basketball player
                  int timesBatted = 0;     //baseball player
                  double battingAvg = 0.0;//baseball player
                  int score = 0;               //hockey player
                  Player [] teamArray = new Player [1];
                 // String cityName = fin.nextLine();
                  if(fin.hasNext())
                        city = fin.nextLine();
                  while (fin.hasNext())
                           String type = fin.nextLine();
                           String firstName = fin.nextLine();
                           String lastName = fin.nextLine();
                           int salary = fin.nextLine();
                           fin.next();//clears buffer
                           if (type.equals("Basketball"))
                               games = fin.nextInt();
                               newPlayer = new Basketball(firstName, lastName, salary);
                           else if (type.equals("Baseball"))
                               battingAvg = fin.nextDouble();
                               timesBatted = fin.nextInt();
                               newPlayer = new Baseball(firstName, lastName, salary);
                           else (type.equals("Hockey"))
                               scoring = fin.nextInt();
                               newPlayer = new Hockey(firstName, lastName, salary);
                           fin.next();//clears buffer
                           teamArray.addPlayer( newPlayer );//call the addPlayer function
                      }//end while
              }//end readPlayers function
              

    The first error is on line 17
    public void readPlayers( fin, teamArray)When declaring a method, you have to indicate the types of the parameters, e.g., public void readPlayers(Scanner fin, Player[] teamArray) {Further, you may NEVER define a method within another method.
    the second error is on line 53
    else (type.equals("Hockey"))type.equals("...") is only for testing equality. It returns a boolean value of true or false. There are two possible solutions here:
    else if (type.equals("Hockey")) //to test if variable "type" is set to the value "Hockey"
    or
    else (type="Hockey") //to force the variable "type" to represent the string "Hockey"
    Which to use depends on what you want to accomplish.

  • Complete BI Beans JSP Application Issues

    Hi,
    I have few issues with using BI Beans in a JSP based web application
    1) I have created a new project of Complete BI JSP Application in Jdeveloper 10. When I run this application there are NULL Pointer exceptions logged on the console. But it doesnt effect the application and the application runs smoothly. Can any one suggest what is causing these NULL pointer exceptions.
    2) Secondly, I want to use my custom logging using log4j for this application, but since everything is done in jsp itself in this application, there is no scope of java classes for logging. Can anyone advise me what is the actual way of doing it.
    Regards,
    Vigo

    peter is right, Use the same driver version as that of your database. Copy the classes12.zip and nls_charset12.zip from database_home\jdbc dir to your application directory.
    Hope it works
    regards
    Mukesh Harjai

  • JSP Code completion DOES NOT WORK in JDev 9.0.3.1

    Does anyone know when the next release of JDev will be? We are seriously considering dropping the use of JDev due to the bugs it has. In particular, the code completion for JSP authoring simply FAILS! This is a very very VERY nasty bug, and we are pleading!!!
    Thanks,
    -Sean

    Works for me.
    What OS/JDK etc are you using?

  • Error on token(jsp error)

    Hi i am writing a code in which i have to call one jsp page from another but as soon as the control gets transferred i get the error msg as:
    Syntax error on token(s), misplaced construct(s)
    16: if(rs.next()==false)
    17: {
    18:
    19: <jsp:forward page="success.jsp"/>
    20:
    21: }
    22: %>
    An error occurred at line: 19 in the jsp file: /second/process.jsp
    Syntax error, insert "AssignmentOperator Expression" to complete Assignment
    16: if(rs.next()==false)
    17: {
    18:
    19: <jsp:forward page="success.jsp"/>
    20:
    21: }
    22: %>
    An error occurred at line: 19 in the jsp file: /second/process.jsp
    Syntax error, insert ";" to complete Statement
    16: if(rs.next()==false)
    17: {
    18:
    19: <jsp:forward page="success.jsp"/>
    20:
    21: }
    22: %>
    An error occurred at line: 19 in the jsp file: /second/process.jsp
    forward cannot be resolved
    16: if(rs.next()==false)
    17: {
    18:
    19: <jsp:forward page="success.jsp"/>
    20:
    21: }
    22: %>
    An error occurred at line: 19 in the jsp file: /second/process.jsp
    The operator / is undefined for the argument type(s) String, void
    16: if(rs.next()==false)
    17: {
    18:
    19: <jsp:forward page="success.jsp"/>
    20:
    21: }
    22: %>
    An error occurred at line: 19 in the jsp file: /second/process.jsp
    Syntax error on tokens, delete these tokens
    16: if(rs.next()==false)
    17: {
    18:
    19: <jsp:forward page="success.jsp"/>
    20:
    21: }
    22: %>
    An error occurred at line: 22 in the jsp file: /second/process.jsp
    Syntax error, insert "}" to complete Statement
    19: <jsp:forward page="success.jsp"/>
    20:
    21: }
    22: %>
    23:
    24: <%
    25: else
    An error occurred at line: 31 in the jsp file: /second/process.jsp
    Syntax error, insert "Finally" to complete TryStatement
    28: <jsp:forward page="fail.jsp"/>
    29: <%
    30: }
    31: }
    32: %>
    33: <%catch(Exception e)
    34: {
    An error occurred at line: 32 in the jsp file: /second/process.jsp
    Syntax error, insert "}" to complete Block
    29: <%
    30: }
    31: }
    32: %>
    33: <%catch(Exception e)
    34: {
    35:
    I am using MS-ACCESS AS DATABASE.
    the jsp code is:
    {color:#ff0000}<%@ page contentType="text/html; charset=UTF-8"%>
    <%@ page import="java.io.{color}{color:#ff0000}*"%>*
    *<%@ page import = "java.sql.*"%>
    <%
    String account=request.getParameter("ac");
    String password=request.getParameter("pass");
    String url="Jdbc:Odbc:Namrata";
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection(url);
    Statement stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery("select from database1 where Account="+account+"and Password="+password);
    if(rs.next()==false)
    <jsp:forward page="success.jsp"/>
    %>
    <%
    else
    %>
    <jsp:forward page="fail.jsp"/>
    <%
    %>
    <%catch(Exception e)
    out.println("the exception is:"+e);
    %>{color}

    Namrata.Kakkar wrote:
    but i have google searched and came to know that in jsp whatever java code we have to write we will write in tagsThat was not very good advice. Like I said, get Sun's Java EE tutorial (it's free) and learn how to do it the correct way.

  • Urgent: how to call servlet from JSP

    I have a working servlet which returns a table in html format. I also updated the web.xml file according to the information I got from the previous message. My problem is how to correctly invoke the servlet in the JSF. I tried the following ways:
    <jsp:include page="/report">
    <jsparams>
    <jsparam name="srcDev" value="#{Page1.srcDevice}"/>
    <jsparam name="tgtDev" value="#{Page1.tarDevice}"/>
    <jsparam name="format" value="complete"/>
    </jsparams>
    </jsp:include>
    and
    <frame src="/report?param1=val1&param2=val2" name="body" frameborder="YES" scrolling="YES" bordercolor="#999999" noresize>
    both doesn't work.I am able to run the servlet within a html form. I just don't know what's the right syntax for calling the servlet inside a JSP page in JSF.
    Can anybody help me?
    Thanks,
    Christine

    Hi Christine,
    This forum is exclusively for Sun Java Studio Creator related issues.
    In case you are using Creator then you can find a sample application named RedirectionExample which makes use of a servlet and would be of help to you. You can find the tutorial on the following page:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
    Cheers
    Giri :-)

  • The page cannot be found or not load completely

    Dear all here,
    I have a jsp+servlet app run on iplanet server, the internal user can access this properly, but external user access with SSL will encounter some error sometimes,
    1, sometimes, the jsp cannot show completely, the jsp page result is very large, according to the selection criteria, it will exceed 5m bytes sometimes. I also found this online, some guys said there should have some exceptions, but I have not found it console or system.out
    2, sometimes the same jsp page cannot be shown, the error page showed in IE browser is "The page cannot be displayed--The page you are looking for is currently unavailable." , but when reopen the page, maybe it be ok
    Did you ever meet that before? could you please kindly give me any advice? I am really frustrated in this...
    Thank you in advance,
    lichunlin

    You were lucky to get it working after changing it back.
    To answer this question:
    Most tables in the data dictionary have very close and often difficult relationships. The data dictionary defines how the database works.
    If you intend to change the dictionary directly, make sure you change ALL the tables that are needed to make the change at the same time. And make sure you make all the changes correctly with accepted values. Changing one value in one table without making appropriate change in all other other related tables generally breaks the functionality of the database. As you found out.
    There is no documentation about this, as Oracle has created applications to do this. The apps are the DDL (create/alter/drop) commands and they are designed to update all the dictionary tables consistently.

  • How to Compile Jsp File in Class File , Protect my JSP from outworld

    Hello Friends
    My name is chandra prakash, I'm new for u. I've develop a web based software completely in JSP, some files are also written in Java Script. This software have aprox. 40 files --> 30 in JSP + 2 in Java Script + 8 image files .
    Each JSP calls another. and run this on 58 clints machine simultaneusly. we used Oracle 9iAS as back end and Oracle9iAS web Server . Where we found less clients like 20-30 we use Tomcat 5.0 web server .Sir problem is this we don't wan't to leave our jsp source code on server.
    Is any method or third party tool by which we can convert our JSP source file in CLASS file as like real class files provide by javac.
    For this perpose we make a folder and put all files in it. Create a context on Tomcat for this folder.Create a data source for this in tomcat. Bcase this program uses Data source and connect many times to database & fetches many type of data from database. We use servlet files of tomcat for this context in WORK folder of Tomcat. and after that rename our Source file Folder. and again run our program through batch file i'm strange program runs 2-3 steps, after few times it start producing errors.
    Sir do u hava work on this field can u help me to protect this JSP source code.
    I've Use Jikes.com compiler but not get any succes, It may be i'm not using correctly .
    Pls sir give me any suggesition.
    Chandra prakash

    1. Highlight your web project or the individual file
    2. Right click
    3. Select Rebuild to build all jsp files or Make to rebuilt only changed files

Maybe you are looking for