Click here to Skip to main content
15,886,584 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ConfigObject.jsp
Java
<% out.print("Driver : "+config.getInitParameter("driver")); %>


web.xml
XML
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    
    <servlet>
        <servlet-name>config</servlet-name>
        <jsp-file>/ConfigObject.jsp</jsp-file>
        <init-param>
            <param-name>driver</param-name>
            <param-value>com.mysql.cj.jdbc.Driver</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>config</servlet-name>
        <url-pattern>/config</url-pattern>
    </servlet-mapping>
</web-app>


Output
Driver : null

What I have tried:

I tried to get the servlet name using config.getServletName() , it worked fine.
But I couldn't figure out why config.getInitParameter("driver") returns null. Suggestions are welcome and thanks in advance:)
Posted
Updated 28-Aug-18 22:11pm
v2
Comments
Herman<T>.Instance 29-Aug-18 4:21am    
and what does "param-name" give as result?
@k5hu 29-Aug-18 7:17am    
It should return com.mysql.cj.jdbc.Driver instead it returns null
Herman<T>.Instance 30-Aug-18 6:24am    
I asked does not should.....
@k5hu 30-Aug-18 6:48am    
That's what it returns null

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900