hi all
 
I'm an absolute newbie to Java, but have programmed in Visual Basic for the last
5 years. I successfully created a Java servlet in Forte for Java Community Edition 3.0,
and viewed it successfully in a web browser.
 
Now, I'd like to add some more info to the webpage that is generated by the servlet.
The servlet uses a method called processRequest, as shown below:
 
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
 
        String temp = null;
        response.setContentType("text/html");
        java.io.PrintWriter out = response.getWriter();
       
        //* output your page here
        out.println("<html>");
        out.println("<head>");
Now, I'd like to add some more output from info read from a database. (I've got that part
working too, thanks to some code I found elsewhere on the 'net.)
Basically, what I'd like to say is:
 
        out.println(LoginForm());
 
where LoginForm is a method that returns a string containing all the HTML for the login page.
I can't use JSP's because all the content is stored in the database, and the DB has its own interface
for managing the content in it, including the Login form.
 
The error I receive from the compiler is:
 
mywebapp.java [62:1] cannot resolve symbol
symbol  : method LoginForm  ()
location: class mywebapp
        out.println(LoginForm());
                       ^
1 error
Errors compiling mywebapp.
 
The LoginForm class is:
 
 
import java.sql.*;
import java.lang.String.*;
 
public class LoginForm {
 
    String temp = null;
   
    /** Creates new LoginForm **/
    public String LoginForm() {
 
       
 
        // open the database here and send the login form
        try
       
        {
 
            // Register JDBC/ODBC Driver in jdbc DriverManager
            // On some platforms with some java VMs, newInstance() is necessary...
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
 
(other code excluded....)
 
       return temp;        /* returns the content of the login form as grabbed from the DB */
 
(other code excluded....)
 
 
Can someone point me in the right direction? Why is LoginForm an unresolved symbol?
I'd rather not put the LoginForm method in the mywebapp servlet, as I supposed that
having multiple classes made things a bit easier for maintenance? ie instead of looking
through all the code in mywebapp if there is a problem with the loginform, I can go straight
to the LoginForm class (ie: LoginForm.java) and edit just that file.
 
 
Thanks for taking the time to help.....
 
 
 
Brad Thomas

Reply via email to