Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6136983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:40:15+00:00 2026-05-23T17:40:15+00:00

I wrote a very simple jsp problem that gets a number from a class

  • 0

I wrote a very simple jsp problem that gets a number from a class and show it but I encountered error 500.

I use eclipse with tomcat 5.5:

 <%@page import="java.io.IOException"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<h1>number of shown :</h1>
<body>
<%
try{
out.print(Model.getCount());
}
catch(IOException k)
{
    out.println("Eror");
}
%>
</body>
</html>

my Model class=>

public class Model {
    static int number=0;
    public static int getCount()
    {
        number++;
        return number;
    }
}

any my model class is default package.

The error I see:

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: 14 in the
jsp file: /show.jsp Model cannot be
resolved 11: 12: <% 13: try{
14: out.print(Model.getCount()); 15: }
16: catch(IOException k) 17: {

Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:328)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:307)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:309)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

note The full stack trace of the root
cause is available in the Apache
Tomcat/5.5.33 logs.


Apache Tomcat

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:40:16+00:00Added an answer on May 23, 2026 at 5:40 pm

    Never put any class in the default package. The default package is not accessible to classes in a package, and since the JSP is transformed in a servlet class by Tomcat, and this class is in a package, it can’t access your Model class.

    Once it’s in a well-defined package, you’ll have to import it, as mschonaker shows in his answer:

    <%@page import="somepackage.Model"%>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've wrote very simple minification/compression handler that minify css and js by indicating request
I just wrote a very simple Expect script for wrapping around rsync, but it
I am learning JSP and Java at the moment and wrote a (very) simple
I want to have a very simple editor for my website that i wrote
I wrote very simple code to understand how columnstretch and calllater work but I
I wrote this very simple function for my current project called insidelabel() that let's
I wrote a very simple web form that allows my user to view text
I wrote a very simple web form that allows my user to view text
I wrote a very simple .Net windows application that sits in the system tray
Let's say I wrote a pretty simple class called ValueFinder that looks like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.