I'm currently working on wrapping the Servlet APIs for a new framework and I thought it might be the perfect opportunity to enhance the API as well. I've made a notable change by converting Enumerations to Iterators, allowing for enhanced for loops. What other issues with the Servlet API do you wish could be addressed?
5 Answers
One major annoyance is how the API returns null instead of empty collections in many cases. It would be much safer to return an empty list instead; it eliminates potential bugs from null checks!
Yeah, the null returns can really complicate things. Just a straightforward change could make a huge difference.
The spec is pretty outdated and could use a refresh. There are so many options missing that would make development easier, like better parameter getters, or improved routing mechanisms.
Yeah, it seems like a thorough update is long overdue, especially with modern practices in mind!
Totally agree. Modernizing would make the API more intuitive and much friendlier to use.
I’m not a fan of how the configuration is handled separately from servlet functions. It's messy to navigate through different scopes. I lean toward JAX-RS or alternatives that offer configuration as code, which is just cleaner.
Yeah, it should be more straightforward. It feels like a design flaw that needs addressing.
Exactly! Having a clear, integrated way to manage configuration makes things so much easier.
The lack of content negotiation support is painful. JAX-RS does a better job in this area. I often wonder why not just switch to that instead?
Right? It seems like such a missed opportunity to streamline development!
Agreed. Content negotiation is crucial and should definitely be improved!
I really prefer an immutable response rather than having functions that mutate a response object. It feels cleaner and reduces side effects, but I understand it might complicate streaming responses.
True; however, mutating can be useful for some cases like streaming. It's a tricky balance!
I’m a huge fan of immutability too! But I’m curious about how it would apply in certain scenarios.
Absolutely! Returning empty collections would definitely help in avoiding NPEs and streamline the code.