Click here to Skip to main content
15,506,209 members
Home / Discussions / Java
   

Java

 
QuestionJava sector best? Pin
Member 127154721-Sep-16 7:42
Member 127154721-Sep-16 7:42 
AnswerRe: Java sector best? Pin
NotPolitcallyCorrect1-Sep-16 8:10
NotPolitcallyCorrect1-Sep-16 8:10 
AnswerRe: Java sector best? Pin
ZurdoDev12-Oct-16 2:08
professionalZurdoDev12-Oct-16 2:08 
QuestionExposing API VS Stored procedure Pin
Java Lead31-Aug-16 5:28
Java Lead31-Aug-16 5:28 
AnswerRe: Exposing API VS Stored procedure Pin
Richard MacCutchan31-Aug-16 5:43
mveRichard MacCutchan31-Aug-16 5:43 
QuestionCan not Access RequestAttribute in JSTL Pin
AmbiguousName26-Aug-16 1:46
AmbiguousName26-Aug-16 1:46 
AnswerRe: Can not Access RequestAttribute in JSTL Pin
rah_sin30-Aug-16 21:07
professionalrah_sin30-Aug-16 21:07 
Question[SOLVED] 'TYPE' Cannot Be Resolved To a Type in JSP Pin
Django_Untaken24-Aug-16 3:34
Django_Untaken24-Aug-16 3:34 
It is solved. Class was in default package. I put it in a package and import that Package.Class in JSP. works like a charm.

================
Hello there. I am attaching two variables with a HttpServletRequest request, an integer and an arraylist. After this when I forward request to a JSP, these casting issues arise. Here is the java servlet code
ArrayList<Employee> list_employees = m_objDbLayer.GetEmployeesAll();
int employee_count = list_employees.size();

request.setAttribute("employee_count", employee_count);
request.setAttribute("list_employees", list_employees);

RequestDispatcher dispatcher = request.getRequestDispatcher("/ViewEmployeesPage.jsp");

dispatcher.forward(request, response);
And here is the JSP code where I access these variables
<%@page import="java.util.ArrayList"%>
<%@page import="/WEB-INF/classes/Employee" %>

<!-- all the starting HTML tags here-->

<%
int employee_count= (int)request.getAttribute("employee_count");
out.println("Total Employees: " + employee_count);

ArrayList<Employee> list_users =new ArrayList<Employee>();
list_users = (ArrayList<Employee>)request.getAttribute("list_employees");
%>
I get these exceptions in server log
<br />
1- Cannot cast from Object to int<br />
2- Employee cannot be resolved to a type<br />

As you can see I am importing Employee class in JSP, what is wrong? Why it can not resolve Employee and convert from object to int? Thanks for any input.

modified 26-Aug-16 6:32am.

QuestionDrools : Exception in thread "main" java.lang.RuntimeException: Query 'results' does not exist Pin
coolSol23-Aug-16 19:37
coolSol23-Aug-16 19:37 
AnswerRe: Drools : Exception in thread "main" java.lang.RuntimeException: Query 'results' does not exist Pin
Richard MacCutchan23-Aug-16 22:02
mveRichard MacCutchan23-Aug-16 22:02 
Questionconsole output to a text file Pin
Member 1142765722-Aug-16 4:55
Member 1142765722-Aug-16 4:55 
AnswerRe: console output to a text file Pin
Richard MacCutchan22-Aug-16 5:28
mveRichard MacCutchan22-Aug-16 5:28 
Rant[REPOST] console output to a text file Pin
Richard Deeming22-Aug-16 5:31
mveRichard Deeming22-Aug-16 5:31 
QuestionShould I use Java over Python for developing web application? Pin
Rebecca199521-Aug-16 13:20
Rebecca199521-Aug-16 13:20 
AnswerRe: Should I use Java over Python for developing web application? Pin
Richard MacCutchan22-Aug-16 0:02
mveRichard MacCutchan22-Aug-16 0:02 
AnswerRe: Should I use Java over Python for developing web application? Pin
manjiriV23-Aug-16 2:56
manjiriV23-Aug-16 2:56 
GeneralRe: Should I use Java over Python for developing web application? Pin
Rebecca199523-Aug-16 5:18
Rebecca199523-Aug-16 5:18 
GeneralRe: Should I use Java over Python for developing web application? Pin
Kofi_Tommy26-Aug-16 14:44
Kofi_Tommy26-Aug-16 14:44 
AnswerRe: Should I use Java over Python for developing web application? Pin
jschell1-Sep-16 7:56
jschell1-Sep-16 7:56 
QuestionHow Android derives from Java Pin
Andy_Bell18-Aug-16 7:34
Andy_Bell18-Aug-16 7:34 
AnswerRe: How Android derives from Java Pin
Richard MacCutchan18-Aug-16 23:27
mveRichard MacCutchan18-Aug-16 23:27 
GeneralRe: How Android derives from Java Pin
Andy_Bell19-Aug-16 0:04
Andy_Bell19-Aug-16 0:04 
GeneralRe: How Android derives from Java Pin
Richard MacCutchan19-Aug-16 0:26
mveRichard MacCutchan19-Aug-16 0:26 
Questionhow to write the console output to text file? Pin
Member 1142765718-Aug-16 1:29
Member 1142765718-Aug-16 1:29 
AnswerRe: how to write the console output to text file? Pin
Richard MacCutchan18-Aug-16 1:36
mveRichard MacCutchan18-Aug-16 1:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.