J
James via JavaKB.com
Hi,
I'm setting up two servlet classes:
issueOptions() (in issueOptions.java) and menuUI() (in menuUI.java).
Both are in the same package: menu.
menuUI has a method inside called issueOverview().
I want to call and execute the issueOverview() method from the issueOptions
class, but how do I do this? I have been trying to do by creating an
instance of the menuUI class, but I cannot be doing correctly. I have
posted the following code (which I hope is useful) and the error produced
upon compiling:
menuUI.java
~~~~~~~~~~~
package menu;
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.DateFormat.*;
import java.util.Date.*;
public class menuUI extends HttpServlet {
//Initialize global variables
.....
......
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection(URL, "", "");
....
....
....
}
}
public void doPost(HttpServletRequest request, HttpServletResponse
response) throws
ServletException, IOException {
....
....
}
public void issueOverview(HttpServletRequest
request,HttpServletResponse response, String issueNo)
throws ServletException, IOException {
....
....
}
}
issueOptions.java
~~~~~~~~~~~~~~~~~
package menu;
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class issueOptions extends HttpServlet {
//Initialize global variables
private Connection connection = null;
private Statement statement = null;
private String query = null;
private int result;
private ResultSet rs = null;
private String URL = "jdbcdbc:myDB";
private menuUI theMenu;
public issueOptions(){
theMenu = new menuUI();
}
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
......
........
}
public void doPost(HttpServletRequest request, HttpServletResponse
response) throws
ServletException, IOException {
........
........
}
public void addComment(HttpServletRequest request,
HttpServletResponse response, String issueNo, String raisedBy, String
commentTitle, String commentDescription) throws ServletException,
IOException {
....
.....
......
if (success = false) {
out.println("<head><title>Comment Details NOT
Submitted</title></head>");
out.println("<body>");
out.println("An error has occurred!");
out.println("<br>The details could not be submitted!");
out.println("<pre><a href=/ILS/addComment.html>Try Again</a></pre>");
out.println("</body>");
out.println("</html>");
out.close();
}
else {
theMenu.issueOverview(request, response, issueNo);
}
}
}
JAVAC ERRORS
~~~~~~~~~~~~
issueOptions.java:22: cannot find symbol
symbol : class menuUI
location: class menu.issueOptions
private menuUI theMenu;
^
issueOptions.java:26: cannot find symbol
symbol : class menuUI
location: class menu.issueOptions
theMenu = new menuUI();
^
2 errors
I'm setting up two servlet classes:
issueOptions() (in issueOptions.java) and menuUI() (in menuUI.java).
Both are in the same package: menu.
menuUI has a method inside called issueOverview().
I want to call and execute the issueOverview() method from the issueOptions
class, but how do I do this? I have been trying to do by creating an
instance of the menuUI class, but I cannot be doing correctly. I have
posted the following code (which I hope is useful) and the error produced
upon compiling:
menuUI.java
~~~~~~~~~~~
package menu;
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.DateFormat.*;
import java.util.Date.*;
public class menuUI extends HttpServlet {
//Initialize global variables
.....
......
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection(URL, "", "");
....
....
....
}
}
public void doPost(HttpServletRequest request, HttpServletResponse
response) throws
ServletException, IOException {
....
....
}
public void issueOverview(HttpServletRequest
request,HttpServletResponse response, String issueNo)
throws ServletException, IOException {
....
....
}
}
issueOptions.java
~~~~~~~~~~~~~~~~~
package menu;
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class issueOptions extends HttpServlet {
//Initialize global variables
private Connection connection = null;
private Statement statement = null;
private String query = null;
private int result;
private ResultSet rs = null;
private String URL = "jdbcdbc:myDB";
private menuUI theMenu;
public issueOptions(){
theMenu = new menuUI();
}
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
......
........
}
public void doPost(HttpServletRequest request, HttpServletResponse
response) throws
ServletException, IOException {
........
........
}
public void addComment(HttpServletRequest request,
HttpServletResponse response, String issueNo, String raisedBy, String
commentTitle, String commentDescription) throws ServletException,
IOException {
....
.....
......
if (success = false) {
out.println("<head><title>Comment Details NOT
Submitted</title></head>");
out.println("<body>");
out.println("An error has occurred!");
out.println("<br>The details could not be submitted!");
out.println("<pre><a href=/ILS/addComment.html>Try Again</a></pre>");
out.println("</body>");
out.println("</html>");
out.close();
}
else {
theMenu.issueOverview(request, response, issueNo);
}
}
}
JAVAC ERRORS
~~~~~~~~~~~~
issueOptions.java:22: cannot find symbol
symbol : class menuUI
location: class menu.issueOptions
private menuUI theMenu;
^
issueOptions.java:26: cannot find symbol
symbol : class menuUI
location: class menu.issueOptions
theMenu = new menuUI();
^
2 errors