This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JSP and the fly likes can any on resolve error  javax.servlet cannot be resolved to a type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "can any on resolve error  javax.servlet cannot be resolved to a type" Watch "can any on resolve error  javax.servlet cannot be resolved to a type" New topic
Author

can any on resolve error javax.servlet cannot be resolved to a type

raj talatam
Ranch Hand

Joined: Apr 19, 2012
Posts: 80
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="antaonlinepkg.*,java.util.ArrayList,java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>DP Entry-No Search Found Form</title>
<script type="text/javascript">
function validate()
{
if(document.getElementById('search_item').value == '')
{
alert("Please Enter Search Item");
return false;
}
if(document.getElementById('search_details').value == '')
{
alert("Please Enter Search Details");
return false;
}
document.getElementById('form_no_search').action = "no_search.jsp";
return true;
}
var popupWindow=null;
function child_popup(user){
popupWindow = window.open('category_action.jsp','width = 400,height = 400,scrollbars=yes');
}
</script>
</head>
<body>
<%
ResultClass result_update=new ResultClass();
result_update.setSchema(session.getAttribute("schema").toString());
String custDate=session.getAttribute("sysdate").toString();
int count = 0;String type="";String desig="";
if(session.getAttribute("type")!=null){type=session.getAttribute("type").toString();}
if(!(session.getAttribute("type").equals(""))){type=session.getAttribute("type").toString();}
if(type.equals("10")){desig = "Data Processor";}else{desig = "Team Leader";}
session.setAttribute("desig",desig);
String query = "Select count(*) as rowcount from no_search_data where username = '"+session.getAttribute("user_tl").toString()+"' and enter_date = '"+custDate+"'";
count = result_update.count(query);
%>
<%!
Connection con;
Statement stmt;
ResultSet res ,res1;
PreparedStatement pstmt;
//String url = "jdbc:mysql://192.168.1.56:3306/";
//String url = "jdbc:mysql://192.168.1.57:3306/";
String url1 = "jdbc:mysql://localhost:3307/";
public void setSchema1(String schema)
{
url1 = url1+schema;
}
public void connect()
{
String user_name = "root";
String pass = "admin";
System.out.println(url1);
String dbclass = "com.mysql.jdbc.Driver";
try
{
Class.forName(dbclass);
}
catch(ClassNotFoundException cnfe)
{
System.out.println("Class Not Found");
cnfe.printStackTrace();
}
catch(Exception e)
{
System.out.println("Other Exception Occured");
}
try
{
con = DriverManager.getConnection(url1,user_name,pass);
}
catch(SQLException e)
{
System.out.println("Not Able To Connect to Database");
}
stmt=null;
}
public ArrayList getData()
{
ArrayList arraydata = new ArrayList();
try{connect();stmt = con.createStatement();res = stmt.executeQuery(" SELECT * FROM no_search_found where access_status = 0 and nsf_item !='' order by nsf_id desc limit 1; ");
if(res.next()){

arraydata.add(res.getInt("nsf_id"));
arraydata.add(res.getString("nsf_item"));
arraydata.add(res.getString("nsf_city"));
arraydata.add(res.getString("nsf_area"));
}
String query3="UPDATE no_search_found set access_status=1 where nsf_id="+arraydata.get(0);
stmt.executeUpdate(query3);
res.close();
stmt.close();
con.close();
url1= "jdbc:mysql://192.168.1.56:3306/";
}
catch(SQLException se){}
return arraydata;
}
%>
<table width="1232" border="0" align="left" cellspacing="0">
<tr>
<td width="303"><strong>Hi <%=session.getAttribute("user_tl").toString() %></strong>,</td>
<td width="353">today you have entered <em><strong><%=count %></strong></em> record(s) upto now.</td>
<%if(type.equals("10")){ %>
<td width="139"><input type="radio" onClick="location.href='/DP_Entry/gateway.jsp'"> Other Forms</td>
<%}%>
<%if(type.equals("20")){ %>
<td width="99"><input type="radio" onClick="location.href='/DP_Entry/gateway.jsp'"> Other Forms</td>
<td width="91"><input type="radio" onClick="location.href='/DP_Entry/tl_select_task.jsp'">Change task</td>
<td width="100"><input type="radio" onclick = "return child_popup('<%=session.getAttribute("user_tl")%>')">Modification</td>
<%} %>
<td width="2"><a href = "/DP_Entry/logout.jsp">Logout</a></td>
</tr>
<tr><td>Designation:<strong><%=desig%></strong></td>
</tr>
</table>
<%
setSchema1("");
ArrayList data = new ArrayList();
setSchema1(session.getAttribute("schema").toString());
data = getData();
System.out.println(data);
String city = "",area = "",item = "";
item = data.get(1).toString();city = data.get(2).toString();area = data.get(3).toString();
setSchema1("");
%>
<br/><br/>
<h3 align="center">No Search Found Form</h3>
<form id = "form_no_search" method = "post" action = "" onSubmit="return validate();">
<input type = "hidden" name = "search_id" value = "<%=data.get(0)%>" id = "search_id" />
<table width="77%" height="124" border="0" align="center">
<tr>
<td width="99" valign="top">Search Item:</td>
<td width="317" valign="top"><input type = "text" name = "search_item" value = "<%=item%>" id = "search_item" /></td>
<td width="78" valign="top">Search City:</td>
<td width="144" valign="top"><input type = "text" name = "search_city" value = "<%=city%>" id = "search_city"/></td>
<td width="90" valign="top">Search Area:</td>
<td width="159" valign="top"><input type = "text" name = "search_area" value = "<%=area%>" id = "search_area"/></td>
</tr>
<tr>
<td valign="top">From Google:</td>
<td height="47" valign="top"><textarea name = "search_details" cols="50" rows="6" id = "search_details"></textarea></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td></td></tr>
<tr>
<td></td>
<td></td>
<td><input type = "Submit" name = "Submit" value = "Submit"></td>
<td> </td>
<td> </td>
<td> </td></tr>
</table>

</form>
<form method = "post" action = "reject.jsp">
<input type = "hidden" name = "search_id" value = "<%=data.get(0)%>" id = "search_id" />
<table width="168" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="168"><input name = "Reject" type = "Submit" id="Reject" value = "Reject"></td>
</tr>
</table>
</form>
<%String search_string = ""; if(!area.equalsIgnoreCase("")){search_string = item+"+"+area;}if(!city.equalsIgnoreCase("")){search_string = item+"+"+city;} String src ="http://www.google.co.in/search?q="+search_string ;%>
<hr/>
<iframe src = "<%=src %>" width = "100%" height="1000px" ></iframe>
</body>
</html>
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
Could you please UseCodeTags ?

And if you can, please post the stack trace of your error. It seems you miss some import there but you said too few about that



Bye,
Nicola
Abdul Aatif
Greenhorn

Joined: Feb 08, 2012
Posts: 23
Why are you writing BusinessLogic in jsp?? divide all MVC can resolve your problem.
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Raj,

Check whether you have added the require jar or not and please post the stack trace and logs.

Regards
Jatan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can any on resolve error javax.servlet cannot be resolved to a type
 
Similar Threads
In the messages module reply is not working
Error comes whilke compiling the jsp page
how to preserve the lastly added contents in table in JSP page?
To call and load javascript in struts jsp.
How to Pass, Username and password and Login from the url