Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Set path of jsp file to open by servlet in netbeans web

Chandrashekhar Patil
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to open jsp file by servlet. but it is not opening.. what is problem in this coding.. my database is saving well. I know how set html coding in servlet. but i wan display my result in just file

jsp file

<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Display User Master</title>
<link href="style/common.css" rel="stylesheet" type="text/css"/>
<link href="style/default.css" rel="stylesheet" type="text/css"/>
<link href="style/ServerControl.css" rel="stylesheet" type="text/css"/>
<form name="frmUserMasterDisplay" method="GET">
<div id="dLogo">
<img id="Img1" alt="MTSU Logo" src="../MTSUJavaProject/images/top_banner.jpg" style="width: 100%;
height: 100px;" />
<div id="dMain" class="dMain" runat="server">
<div id="dBaseContainer" class="dBaseContainer" style="width:820px; position: absolute; margin-left: 220px;">
<div id="dHead" class="dHead" runat="server" style="background-color: Maroon; color: #FFFFFF;
width: 620px; margin-left: 100px; top: 50px; position: absolute; font-size: small;">
<div id="dContiner" class="dContainer">
<div class="Box-Full">
<table border="1">
<th>User Id</th>
<th>Person Name</th>
<th>User Name</th>
<th>Email ID</th>
UserMasterViewLogic eb = new UserMasterViewLogic();
List<UserMasterEntity> list = eb.getEmployees();
for (UserMasterEntity e : list) {
<td><%= e.UserId %></td>
<td><%= e.PersonName%></td>
<td><%= e.UserName%></td>
<td><%= e.Password.toString() %></td>
<td><%= e.EmailID %></td>

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import static java.lang.System.out;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
* @author Shailin
public class UserMasterLogic extends HttpServlet {

String PersonName,UserName,Password,EmailID;
String query,Selectquery;
Connection conn;
Statement smts;
ResultSet res;
Data dbConn;
int intAnswer;
UserMasterViewLogic userMasterViewLogic;
UserMasterEntity userMasterEntity;

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try (PrintWriter out = response.getWriter()) {

userMasterEntity = new UserMasterEntity();

dbConn = new Data();

conn = dbConn.SetConnetion();
smts = conn.createStatement();

userMasterEntity.PersonName = request.getParameter("tbPersonName");
userMasterEntity.UserName = request.getParameter("tbUserName");
userMasterEntity.Password = request.getParameter("tbPassword");
userMasterEntity.EmailID = request.getParameter("tbEmailID");

conn = dbConn.SetConnetion();
smts = conn.createStatement();

query = "Insert into Users(vPersonName, vUserName, vPassword, vEmailID)" +
" Values ('" + userMasterEntity.PersonName + "','" + userMasterEntity.UserName + "','" +
userMasterEntity.Password + "','" + userMasterEntity.EmailID+ "')";
intAnswer = smts.executeUpdate(query);

if(intAnswer == 1)
userMasterViewLogic = new UserMasterViewLogic();
request.getRequestDispatcher("/UserMasterDisplay.jsp").forward(request, response);
else if(intAnswer == -1)
out.println("<script type='text/javascript'>");
out.println("window.alert('Data Failed....')");
}catch(SQLException ex)
throw new ServletException(ex);

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic