• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servletConfig gives me null

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator






I am using servletconfig here, and used initparameter, but this gives me null why?
Screenshot_7.png
[Thumbnail for Screenshot_7.png]
Output is null
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I find your lack of proper indentation disturbing.
 
sarojni agrwal
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



sorry , this is my web.xml with proper indentation.
 
Marshal
Posts: 4499
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a couple of things you need to sort out.

First, the configuration in the web.xml has problems: the servlet-class is incorrect (doesn't match your Servlet), and the url-pattern doesn't match what you are typing in the browser (doesn't matter at the moment due to the second issue).

Second, you are using both an annotation and a deployment descriptor. While that is allowed, when you have the errors with one or the other, things can appear to be working, but not completely or as expected. Maybe for now, you should use one or the other. IF you want to specify the init params and other configuration data in the annotation rather than the web.xml file, you can annotate the Servlet like this:

    @WebServlet(name="anyname", urlPatterns={"/servletconfg"},initParams={@WebInitParam(name="Driver", value="trapti")})
 
sarojni agrwal
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know , "servlet class"(which is given in web.xml) is the package name of servlet ...according to you ,what should be my "servlet- class" in web.xml?
 
sarojni agrwal
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the above reply , actually, the "servlet-class" is somewhat full pacakage name with class name, I got my answer, btw thanks for reply...
 
reply
    Bookmark Topic Watch Topic
  • New Topic