Can anybody plz help me outof this problem in mah code

Joined
Nov 17, 2011
Messages
1
Reaction score
0
description The requested resource (/mcportal/jsp/=%22../editemp%22) is not available.
mg is displaying whenever i am running mah jsp..page which is calling a servlet which is searching the emp_name and emp_id in db n if it matches it redirects it to the previous page with the user details..

The code is given below...

Servlet Code;;;;;;;;;;




import java.io.IOException;
import javax.servlet.http.HttpSession ;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.sql.*;

public class editemp extends HttpServlet {
Connection activeConnection = null;
Statement st1=null;
PreparedStatement ps=null, ps1=null;
ResultSet rs=null ,rs1=null;
HttpSession hs=null;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();
String name=request.getParameter("emp_name");
String id=request.getParameter("emp_id");
try{

activeConnection = OracleConnectionUtil.getConnection();
st1=activeConnection.createStatement();


String s="select * from EMPLOYEE_DETAILS where EMPLOYEE_NAME=? AND EMPLOYEE_ID=?";
String emp="select emp_id from EditEmployee where emp_id=? ";
ps=activeConnection.prepareStatement(s);
ps1=activeConnection.prepareStatement(emp);
ps1.setString(1, id);
ps.setString(1, id);
ps.setString(2, name);
rs=ps.executeQuery();
if(rs.next())
{
if(rs.getString("EMPLOYEE_ID").equals("emp_id"))
{
System.out.println("1");
rs1=ps1.executeQuery();
if(rs1.next())
{
System.out.println("2");
if(rs1.getString("EMPLOYEE_NAME").equals("emp_name"))
{
System.out.println("3");
HttpSession hs=request.getSession(true);
System.out.println(hs.getId());
System.out.println(hs.isNew());
hs.setAttribute("emp_id", id);
hs.setAttribute("emp_name","name" );
System.out.println("3");
response.sendRedirect("/mcportal/jsp/addnewemp.jsp");

}
else
{
hs=request.getSession();
hs.setAttribute("emp_id",id);
hs.setAttribute("emp_name",name);
response.sendRedirect("/mcportal/jsp/addnewjsp.jsp");
}}

else


{

response.sendRedirect("mcportal/jsp/editemp.jsp?in=2");


}
}
}
}
catch(SQLException se)
{
out.print(se.getMessage());
}
finally{
try{
activeConnection.close();
ps.close();
rs.close();
}
catch(Exception e){
out.println(e.getMessage());
}
}

out.flush();
out.close();
}

}



addnewemp.jsp






<meta http-equiv="cache-control" content="no-cache"> <!-- tells browser not to cache -->

<meta http-equiv="expires" content="0"> <!-- says that the cache expires 'now' -->

<meta http-equiv="pragma" content="no-cache"> <!-- says not to use cached stuff, if there is any -->



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<%
String JspPath =request.getContextPath()+"/jsp/" ;
%>
<script language=javascript>

javascript:window.history.forward(1);

window.onbeforeunload = function (){}

</script>

<script language="javascript" type="text/javascript" src="<%=JspPath%>JavaScript/addnewemp.js">
</script>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="include/cms.css" rel="stylesheet" type="text/css" />

<title>Employee Details</title>

</head>

<body>

<form id="EmployeeDetails" name="EmployeeDetails" method="post" action="<%=request.getContextPath()%>/CreateEmployeeDetail" >

<table width="100%" height="60%" border="0" cellpadding="0" cellspacing="0">

<tr width="100%">

<td width="10%" height="26">&nbsp;</td>

<td width="64%" align="center" valign="bottom"><img src="images/blackberry_top_bg_new.jpg" width="100%"/></td>

<td width="26%">&nbsp;</td>

</tr>

<tr>

<td>&nbsp;</td>

<td align="center" valign="bottom"><table width="99%" height="100%" border="0" cellpadding="1" cellspacing="0" bgcolor="#F7F7F7" id="formatedTab">

<tr>

<th colspan="3" align="center" valign="top" >Employee Details</th>

</tr>

<tr>

<th width="44%" align="right" valign="top" >&nbsp;</th>

<td width="6%">&nbsp;</td>

<td width="50%">&nbsp;</td>

</tr>



<tr>

<th width="44%" align="right" valign="top" scope="row">Employee Name</th>

<td>&nbsp;</td>

<td width="50%"><label>

<input name="emp_name" type="text" class ="contentblack" id="emp_name" size="20" maxlength="50"/>

</label></td>

</tr>
<tr>
<th width="44%" align="right" valign="top" scope="row">Marital Status</th>
<td>&nbsp;</td>
<td width="50%">
<INPUT TYPE="radio" NAME="m_status" Value="Single"><label>Single</label>
<INPUT TYPE="radio" NAME="m_status" Value="Married"><label>Married</label>
</td>
</tr>
<tr>

<th width="44%" align="right" valign="top" scope="row">E-Mail Id</th>

<td>&nbsp;</td>

<td width="50%"><label>

<input name="email_id" type="text" class ="contentblack" id="emailid" size="20" maxlength="50"/>

</label></td>

</tr>




<tr>

<th width="44%" align="right" valign="top" scope="row">mCarbon User ID</th>

<td>&nbsp;</td>

<td width="50%"><label>

<input name="emp_id" type="text" class ="contentblack" id="emp_id" size="20" maxlength="50"/>

</label></td>

</tr>


<tr>

<th width="44%" align="right" valign="top" scope="row">Department</th>

<td>&nbsp;</td>

<td width="50%">

<select name="dept" id="department" class ="contentblack" >

<option value="-1" >Select the Department</optiion>

<option value="DEVELOPMENT">DEVELPOMENT</option>

<option value="PRODUCT">PRODUCT</option>

<option value="MARKETING">MARKETING</option>

<option value="SALES">SALES</option>

<option value="OPERATION">OPERATION</option>

<option value="SUPPORT">SUPPORT</option>


</select>

</td>

</tr>



<tr>

<th width="44%" align="right" valign="top" scope="row">Blood Group</th>

<td>&nbsp;</td>

<td width="50%">

<select name="bgroup" id="bloodgroup" class ="contentblack" >

<option value="-1" >Select the BloodGroup</optiion>

<option value="O+">O+</option>

<option value="A+">A+</option>

<option value="B+">B+</option>

<option value="AB+">AB+</option>

<option value="O-">O-</option>

<option value="A-">A-</option>

<option value="B-">B-</option>

<option value="AB-">AB-</option>





</select>

</td>

</tr>

<tr>

<th width="44%" align="right" valign="top" scope="row">Passport Number</th>

<td>&nbsp;</td>

<td width="50%"><label>

<input name="passport" type="text" class ="contentblack" id="passportnumber" size="20" maxlength="50"/>

</label></td>

</tr>



<tr>

<th width="44%" align="right" valign="top" scope="row">Account Number</th>

<td>&nbsp;</td>

<td width="50%">

<input name="accountNo" type="text" id="accountnumber" size="20" maxlength="50" class ="contentblack">

</td>

</tr>



<tr>

<th width="44%" align="right" valign="top" scope="row">Permanent Address</th>

<td>&nbsp;</td>

<td width="50%">

<input name="permanentAdd" type="text" id="permanentaddress" size="20" maxlength="50" class ="contentblack">

</td>

</tr>


<tr>

<th width="44%" align="right" valign="top" scope="row">Present Address</th>

<td>&nbsp;</td>

<td width="50%">

<input name="presentAdd" type="text" id="presentaddress" size="20" maxlength="50" class ="contentblack">

</td>

</tr>






<tr>

<th width="44%" align="right" valign="top" scope="row">Mobile Number</th>

<td>&nbsp;</td>

<td width="50%" align="left"><label>



<input name="mobile" type="text" id="mobilenumber" size="15" maxlength="15" class ="contentblack" />





</label></td>

</tr>



<tr>

<th width="44%" align="right" valign="top" scope="row">Alternate Number</th>

<td>&nbsp;</td>

<td width="50%" align="left"><label>



<input name="alternateNo" type="text" id="alternatenumber" size="15" maxlength="15" class ="contentblack">





</label></td>

</tr>




<tr>

<th width="44%" align="right" valign="top" scope="row">Extension Number</th>

<td>&nbsp;</td>

<td width="50%" align="left"><label>



<input name="extensionNo" type="text" id="extensionnumber" size="15" maxlength="15" class ="contentblack" />





</label></td>

</tr>




<tr>

<th width="44%" align="right" valign="top" scope="row">Location</th>

<td>&nbsp;</td>

<td width="50%" align="left"><label>



<input name="location" type="text" id="location" size="20" maxlength="20" class ="contentblack">





</label></td>

</tr>








<tr>

<th colspan="3" align="center" valign="top" scope="row"><input type="submit" name="submit" id="submit" value="Submit" onclick="javascript: return doSubmit()" /></th>

</tr>

</table></td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="10%" height="26">&nbsp;</td>

<td width="64%" align="center" valign="top"><img src="images/blackberry_bottom.gif" width="100%"/></td>

<td width="26%">&nbsp;</td>

</tr>

</table>

</form>

</body>

</html>





now second jsp page code is...






<meta http-equiv="cache-control" content="no-cache"> <!-- tells browser not to cache -->

<meta http-equiv="expires" content="0"> <!-- says that the cache expires 'now' -->

<meta http-equiv="pragma" content="no-cache"> <!-- says not to use cached stuff, if there is any -->



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<%
String JspPath =request.getContextPath()+"/jsp/" ;
%>
<script language=javascript>

javascript:window.history.forward(1);

window.onbeforeunload = function (){}

</script>

<script language="javascript" type="text/javascript" src="<%=JspPath%>JavaScript/editemp.js">
</script>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="include/cms.css" rel="stylesheet" type="text/css" />

<title>Edit Employee</title>

</head>

<body>

<form action=="../editemp" method="get">

<table width="100%" height="60%" border="0" cellpadding="0" cellspacing="0">

<tr width="100%">

<td width="10%" height="26">&nbsp;</td>
<td width="64%" align="center" valign="bottom"><img src="images/blackberry_top_bg_new.jpg" width="100%"/></td>

<td width="26%">&nbsp;</td>

</tr>

<tr>

<td>&nbsp; </td>

<td align="center" valign="bottom"><table width="99%" height="100%" border="0" cellpadding="1" cellspacing="0" bgcolor="#F7F7F7" id="formatedTab">

<tr>

<th colspan="3" align="center" valign="top" >Edit Employee</th>

</tr>

<tr>

<th width="44%" align="right" valign="top" >&nbsp;</th>

<td width="6%">&nbsp;</td>

<td width="50%">&nbsp;</td>

</tr>



<tr>
<th align="right" scope="row">Employee Name</th>
<td scope="row">&nbsp;</td>
<td scope="row"><label>
<input type="text" name="emp_name" id="emp_name" class ="contentblack">
</label></td>
</tr>


<tr>
<th align="right" scope="row">mCarbon User ID</th>
<td scope="row">&nbsp;</td>
<td scope="row"><label>
<input type="text" name="emp_id" id="employeeid" class ="contentblack">
</label></td>
</tr>

<tr>
<th colspan="3" align="center" scope="row"><label>
<input type="Submit" name="search" id="search" value="Search">
</label></th>
</tr>
<tr>
<th colspan="3" scope="row" align="center">&nbsp;</th>
</tr>
</table></td>
<td>&nbsp;</td>
</tr>






<tr>

<td width="10%" height="26">&nbsp;</td>

<td width="64%" align="center" valign="top"><img src="images/blackberry_bottom.gif" width="100%"/></td>

<td width="26%">&nbsp;</td>

</tr>

</table>

</form>

</body>

</html>




please correct mah problem...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top