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 6969801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:37:39+00:00 2026-05-27T16:37:39+00:00

I’m studying servlets and I’m trying to create a small program to get the

  • 0

I’m studying servlets and I’m trying to create a small program to get the hour through a class that I’ve created. But I’ve bee getting a exception. Here is the code:

User

package Business;

public class User {

    private String userId;

    public User() {
        userId = "";
    }

    public User(String id) {
        userId = id;
    }

    public void setUserId(String id) {
        userId = id;
    }

    public String getUserId() {
        return userId;
    }

}

Hours

package Business;

import java.util.Calendar;
import java.util.GregorianCalendar;

import business.User;

public class Hours {

    private User user;
    private Calendar cal = new GregorianCalendar();
    private int min = 0;

    public Hours(User user) {
        this.user = user;
        min = cal.get(Calendar.MINUTE);
    }

    public String getMinutes() {
        return Integer.toString(min);
    }

    public User getUser() {
        return user;
    }

}

CheckUser

package process;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Business.User;
import Business.Hours;

public class CheckUser extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String userId = request.getParameter("userID");
        User user1 = new User(userId);
        Hours h1 = new Hours(user1);
        String url = "/show.jsp";

        request.setAttribute("hours", h1);

        RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
        dispatcher.forward(request, response);

    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String userId = request.getParameter("userID");
        User user1 = new User(userId);
        Hours h1 = new Hours(user1);
        String url = "/show.jsp";

        request.setAttribute("hours", h1);

        RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
        dispatcher.forward(request, response);
    }


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String userId = request.getParameter("userID");
        User user1 = new User(userId);
        Hours h1 = new Hours(user1);
        String url = "/show.jsp";

        request.setAttribute("hours", h1);

        RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
        dispatcher.forward(request, response);
    }

}

Index

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Project</title>
    </head>
    <body>
        <h1>Employees</h1>
        <form action="<%=response.encodeURL("CheckUser")%>" method="get">
            <input type="submit" value="Diogo">
            <input type="hidden" name="userId" value="1">
        </form>
    </body>
</html>

Show

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%@ page import="Business.*, process.*" %>

        <%
            Hours h1 = (Hours) request.getAttribute("hours");
            String userId =h1.getUser().getUserId();
        %>
        <h1><%= userId %></h1>
    </body>
</html>

Exception

type Exception report

message

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

exception

java.lang.RuntimeException: Uncompilable source code – Erroneous ctor sym type: process.CheckUser.doGet(CheckUser.java:37)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722) note The
full stack trace of the root cause is available in the Apache
Tomcat/7.0.23 logs.

  • 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-27T16:37:39+00:00Added an answer on May 27, 2026 at 4:37 pm

    your package is package Business; but Hours class you have used import business.User;
    remember package is case sensitive and as per standard it should be in lowercase

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.