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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:41:13+00:00 2026-05-23T19:41:13+00:00

I’m writing a front controller servlet class for webapps. The front controller is designed

  • 0

I’m writing a front controller servlet class for webapps. The front controller is designed to differentiate between three basic cases:

  1. File request (calling a FileRequestHandler instance)
  2. Data request (calling a DataRequestHandler instance)
  3. Servlet request (calling a ServletRequestHandler instance)

For testing I wanted to use Tomcat’s DefaultServlet (javadoc,source code) to serve files but I cannot get it to work. The problem is that even though my FileRequestHandler class should properly extend the DefaultServlet I cannot access its protected methods (specifically doGet for handling GET requests). The classes are in different packages btw.


Code:

public class FileRequestHandler extends DefaultServlet {

// fields

    private static final long serialVersionUID = 1L;

// methods

    public void setResponse(HttpServletRequest request , HttpServletResponse response, URI uri) 
            throws IOException, ServletException 
    {
                                                                                                                                    /* DEBUG */try {
            System.out.println("(!!) doGet >> " + DefaultServlet.class.getMethod("doGet",new Class[]{HttpServletRequest.class,HttpServletResponse.class}) ) ;
            doGet(request,response) ;
                                                                                                                                    /* DEBUG */}
                                                                                                                                    /* DEBUG */catch(Exception e) { System.out.println("(!) " + this.getClass( ).getName( ) + " >> buildResponse >> " + e.toString( ) ) ; }
    }

 }

Stack trace:

(part leading up to the NullPointer)

at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:741)
at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:398)
at org.pulse.web.FileRequestHandler.buildResponse(FileRequestHandler.java:39)


Update:

I maybe have to clarify that the front controller servlet will intercept all HttpRequests, (<url-pattern>/</url-pattern> in web.xml) to the effect that DefaultServlet instantiated by the servlet container will not receive any requests, as far as I can tell.
I have now explicitely called DefaultServlet#init in the front controller class:

 FileRequestHandler fileRequestHandler = new FileRequestHandler( ) ;
 fileRequestHandler.init( ) ;

Now I end up with a 404 Servlet is not available.

Update2: The problem — as turns out — actually is a follow-up problem with inadequate use of the extended class rather than a direct problem with inheritance.


The post to the Log which I added to detect the problem’s root will provoke a NoSuchMethodException.. If I omit it I’ll get a NullPointerException.

It looks ever so simple. Still I can’t get it to work the way I want it to. Any ideas, suggestions or insights?

TIA,

FK

  • 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-23T19:41:14+00:00Added an answer on May 23, 2026 at 7:41 pm

    Class.getMethod returns public methods – there’s no such public method, hence the exception. You can use getDeclaredMethod to get non-public methods.

    It’s not clear why you were getting a NullPointerException when you tried it without the logging – if you can post a fuller stack trace, it may be clearer.

    EDIT: Judging by the source code for DefaultServlet it looks like this is the line throwing the exception:

    CacheEntry cacheEntry = resources.lookupCache(path);
    

    That doesn’t make much sense though, as init() should have thrown an exception in that case… is there anything else reporting an error in your logs?

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
I am writing an app with both english and french support. The app requests
I have a reasonable size flat file database of text documents mostly saved in
I'm parsing an XML file, the creators of it stuck in a bunch social
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.