Skip to content

Conversation

@sonalsk
Copy link
Collaborator

@sonalsk sonalsk commented Feb 1, 2020

Created Controller Servlet

private ItemDBC itemDBC;

public void init() {
String jdbcURL = getServletContext().getInitParameter("jdbcURL");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Init is not needed. You can craete a default constructor of the servlet and call getConnection function
Connection con = itemDBC.getConnection();

private static String jdbcPassword;
private static Connection jdbcConnection;

public ItemDBC(String jdbcURL, String jdbcUsername, String jdbcPassword) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ome way to do is to create a default contsructor and create a separate properties files to define the jdbc url, username or password.
Otherwise you can directly assign values

public ItemDBC(){
this.jdbcURL = " Manually define here the url"
}


protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String action = request.getServletPath();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a session variable on your JSP instead and just get the value from that page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants