FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


JSP Help!!!





NewGuyinTown
I want to import the following classes:

Code:
DatabaseController.class
TeamMember.class
User.class

Path to the classes: db\classes (don't know if the path makes a difference)

server: JBoss Application Server
host: localhost:8090
database: mySQL

How would I do it?

Thank you.
Nyizsa
Code:
<% page import="DatabaseController.class,TeamMember.class,User.class" %>

The path usually makes a difference, at least in Tomcat. Classes should be located in /WEB-INF/classes.
NewGuyinTown
Thanks... when importing, it gives me an error: "Syntax error on token "class", Identifier expected"

I tried importing with *, then tried using the class... it say that it could not resolve DatabaseController...

Code:
public interface User{
    public String getFirstName();
    public String getLastName();
    public String getFullName();
    public String getRole();
}


Code:
public class TeamMember implements User{

    private String
        SSOID,
        firstName,
        lastName,
        email,
        costCenter,
        classification,
        pole,
        function,
        mSSOID,
        mFirstName,
        mLastName,
        mEmail;
   
    public TeamMember( String SSOID, String firstname, String lastname, String email,
        String costcenter, String classification, String pole, String function,
        String mSSOID, String mfirstname, String mlastname, String memail ){
       
        this.SSOID = SSOID;
        this.firstName = firstname;
        this.email = email;
        this.costCenter = costcenter;
        this.classification = classification;
        this.pole = pole;
        this.function = function;
        this.mSSOID = mSSOID;
        this.mFirstName = mfirstname;
        this.mLastName = mlastname;
        this.mEmail = memail;
    }
   
    public String getFirstName(){
        return firstName;
    }
    public String getLastName(){
        return lastName;
    }
    public String getFullName(){
        return firstName + " " + lastName;
    }
    public String getRole(){
        return "Team Member";
    }
}


Code:
import java.io.*;
import java.lang.*;
import java.sql.*;

public class DatabaseController{
   
    private static final String roles[] = { "Team Member", "Employee Manager", "Project Owner", "Organization Leader", "Administrator" };
    public DatabaseController(){
    }
   
    public static User login( String SSOID, String password ){
        try{
           
            Connection db = DriverManager.getConnection("jdbc:mysql://localhost/caplabortool");
            PreparedStatement sql = db.prepareStatement("SELECT * FROM user WHERE SSOID = " + SSOID);
            ResultSet results = sql.executeQuery( );
            if( results.getString( "Password" ).equals( password ) ){
                String role = results.getString( "Classification" );
                if( role.equals( roles[0] ) ){
                    return new TeamMember(
                        results.getString( "SSOID" ),
                        results.getString( "Last Name" ),
                        results.getString( "First Name" ),
                        results.getString( "Email" ),
                        results.getString( "Cost Center" ),
                        results.getString( "Classification" ),
                        results.getString( "Pole" ),
                        results.getString( "Function" ),
                        results.getString( "Manager SSOID" ),
                        results.getString( "Manager Last Name" ),
                        results.getString( "Manager First Name" ),
                        results.getString( "Manager Email" )
                    );
                }
            }
        }
        catch( Exception err ){
        }
        return null;
    }
    public static void userUpdate( ){
        try{
            Connection db = DriverManager.getConnection("jdbc:mysql://localhost/caplabortool");
        }
        catch( Exception err ){
        }
    }
}


Code:
<%@ page language="java" import="User.*, TeamMember.*, DatabaseController.*" %>
<%!   String SSOID = "0"; %>
<%!   String password = "0"; %>

<%   boolean teamMember = false ; %>
<%   boolean projectOwner = false ; %>
<%   boolean organizationLeader = false ; %>
<%   boolean administrator = false ; %>

<%

if(request.getParameter("SSOID") != null){
   session.setAttribute( "SSOID", request.getParameter("SSOID") );
   SSOID = session.getAttribute("SSOID").toString();
   session.setAttribute( "password", request.getParameter("password") );
   password = session.getAttribute("SSOID").toString();
   User user = DatabaseController.login( SSOID, password );
   teamMember = true;
}


%>


Quote:
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 10 in the jsp file: /frontend/main_menu.jsp
Generated servlet error:
User cannot be resolved to a type

An error occurred at line: 10 in the jsp file: /frontend/main_menu.jsp
Generated servlet error:
DatabaseController cannot be resolved


org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


root cause

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 10 in the jsp file: /frontend/main_menu.jsp
Generated servlet error:
User cannot be resolved to a type

An error occurred at line: 10 in the jsp file: /frontend/main_menu.jsp
Generated servlet error:
DatabaseController cannot be resolved


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
NewGuyinTown
Ok resolved the importing issue.

When I use the DriverManager.getConnection( ... ) in a jsp file, it works... but when I imported a java class into a jsp with a DriverManager.getConnection in the java class, it does not work, anyone know the reason why it is not working?
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.