|
|
Hello there. I am trying to get rid of scriptlets. I attach an object from servlet and try to access it in JSTL. But the logs say that JSP can not find the properties of this object. Here is the servlet sample
request.setAttribute("student", student);
Here is the JSTL sample, with different combinations - all producing no result at all (how ever scriptlets do)
<c:set var="student" value='${requestScope.student}' scope="request" />
<input type='text' value='${student.FirstName}' />
<input type='text' value='${student.FirstName}' />
<input type='text' value='<c:out value='${student.FirstName}' />' />
<input type='text' value=<c:out value='${student.FirstName}' /> />
As you can see, I have tried different combinations but could not get and display value of request attribute using JSTL. What is wrong? Thanks for any input.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
|
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.
|
|
|
|
|
Hi All,
I am getting exception as Query result does not exist after calling the mehod QueryResults in drools.
qResults = kSession.getQueryResults ("results");
Is there any drools expert on coderanch who can help me to resolve the exception.
Please let me know if you need additional information.
Thanks,
|
|
|
|
|
The message is telling you what the problem is. The query named "results" cannot be found. Check your system settings, configuration etc, or wherever the queries are stored. See also https://docs.jboss.org/jbpm/v5.1/javadocs/org/drools/runtime/rule/WorkingMemory.html#getQueryResults(java.lang.String, java.lang.Object...).
|
|
|
|
|
i had wrote a code to connect to remote oracle data & execute query to find a task whether to check running or not...
I am getting the output in the console, but i need to print the console output to a file..
eg:
while(re.next){
executeing the query(select * from product_inventory_task)
acutally code connects to mutiple server & get the result.
while printing the result to text file ,it prints only the last value stored query reslut
|
|
|
|
|
Member 11427657 wrote: while printing the result to text file ,it prints only the last value stored query reslut So there is obviously a bug in your code. But since we cannot see your code we have no idea what that bug may be. I already gave you a suggestion to your previous post on this issue, at Re: how to write the console output to text file? - Java Discussion Boards[^]. Did you follow the link I provided?
|
|
|
|
|
|
I am a Java developer and I love Java to the core. I always wanted to learn the skills for creating web applications but never really got the time for it. But, lately I wanted to challenge myself to learn and create a web application. Now, here is the dilemma:-
I did some research before actually starting to develop the web application. I have narrowed my option down to two:- a. Use Java (learn JSP and servlets) - my heart is biased towards this approach. b. Use Python and Django framework - my mind is biased towards this approach. Now, I did some research on the Django framework and found a lot of positive reviews whereas I also found mixed reactions on the web regarding the use of Java for web applications. Consider me completely naive to the world of web applications as this will be my first time and it's nothing industry related or work. It's just a tool and knowledge that I want to learn.
I went on and followed some tutorials on Django but honestly, I din't really enjoy it that much but I am still open to giving it a shot.
So, my question is Will I be at a disadvantage if I create web applications using Java using the JSP and Servlets or should i follow the new trend of using Django and Python? Where could I miss the edge if I use Java over Python?
|
|
|
|
|
Rebecca1995 wrote: Will I be at a disadvantage if There is no way to answer such a question, beyond saying go with what you find interesting and enjoy. If you are looking to develop professional skills, then you need to research what skills are in demand where you live.
|
|
|
|
|
i think one should follow his heart instead of running behind trend.If u listen to your heart u will be more successful because u love what u r doing.Talking about java... It a wonderful language loved by many.and it will never face any crises for sure.so go for java..get mastery over it and concure the web world. to start with i will suggest
1. Get perfect in syntax
2. Create some sample project not so bulky but small
3. try to improve last done project by adding something new
4. imagine things around you which can be module in servlets and jsp format
5.try to find out market for your work done this will give you financial benefit and so you will get motivated to work harder
finally i wish almighty to give all the success
|
|
|
|
|
|
Thanks for your advice,think i should also do the same by mastering one programming language for now.I think i will opt for java
|
|
|
|
|
Rebecca1995 wrote: web application. ... (learn JSP and servlets) -
I will note that I have been doing this for a while and it does depend on what you mean by "web application" but I haven't seen anyone using JSP and servlets for quite some time.
In terms of general java expertise the idioms applicable to actually using those will apply to other stuff (quite a bit actually in the modern world) so you could do that. But be careful to learn why each of those has different semantics rather than just learning how to implement each. Or more specifically learn how class loading works in depth.
|
|
|
|
|
I'm studing Android language in Android Studio. I know that Anrdoid language is derived by Java, but I desired to review my knowledge on Java programming. So, how is Android libraries similar to Java? Can I find in Java packages and programming-techniques the same components like: Broad Cast Reciver, Intent, Intent Filter and so on?
|
|
|
|
|
Classes unique to Android are not necessarily in mainstream Java since they have no relevance outside the Android framework.
|
|
|
|
|
Thank you for repaly. So I can't find in Java "component" or resources like Intent, BroadCast Receiver and so on... Isn't it? How can I replace those (i.e. event, event handler, back ground task)?
|
|
|
|
|
|
i doing a jdbc connectivity to connect to a remote oracle databases & running a query & the query result are show in console.
OUTPUT:
backup Taskintiated
done for 1st.
backup Taskintiated
done for 2st.
I want this console output to a text file..
|
|
|
|
|
|
public class sampl{
private static final boolean Null = false;
static String store = null;
static String ip = null;
static String port= null;
static String username = null;
static String password = null;
static String sid = null;
static String get = null;
static String s;
static String v="success";
static String sa = null;
static String fullstr = null;
String[] spl= null;
int i = 0;
public static void main(String[] args) throws FileNotFoundException {
{
String csvFile = "C:\\purge_test\\sam.csv";
BufferedReader br = null;
String line =null;
String cvsSplitBy = ",";
String[] spl= null;
String detail[]=null;
try {
br = new BufferedReader(new FileReader(csvFile));
// System.out.println("*****");
while ( (line = br.readLine() ) != null) {
// System.out.println("inside");
// use comma as separator
detail = line.split(cvsSplitBy);
// System.out.println("server ip = " + detail[1] +"\tport = " + detail[2] + "\tUsername"+ detail[3]+"\tPassword = "+ detail[4]+"\tSID = "+ detail[5]);
try{
store =detail[0];
ip = detail[1];
port= detail[2];
username = detail[3];
password = detail[4];
sid = detail[5];
int po = Integer.parseInt(port);
//step1 load the driver class
Class.forName("oracle.jdbc.driver.OracleDriver");
String a = "jdbc:oracle:thin:@"+ip+":"+po+":"+sid;
// System.out.println("string a:" + a);
// System.out.println("usrname:"+username);
//.out.println("pswd:"+password);
//step2 create the connection object
Connection con=DriverManager.getConnection(a,username,password);
// Connection con=DriverManager.getConnection(
// "jdbc:oracle:thin:@172.26.64.50:1521:xe","OATXPRESS","Ckpoatorapw1234");
//
//
//System.out.println("qqqq");
//Connection con=DriverManager.getConnection("a",username,password);
//step3 create the statement object
Statement stmt=con.createStatement();
// System.out.println("rrrr");
// java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
//step4 execute query
ResultSet rs=stmt.executeQuery("select TASK_NAME,to_char(START_TIME,'DD-MON-YYYY HH24:MI:SS') as RUN_TIME,case when count(*) > 0 then 'Task Initiated' else 'Task Not Initiated' end as \"TASK_Status\" from TMS_TASK_LOG where (TASK_NAME='purge_database' or TASK_NAME='db_stats_collection') and to_char(START_TIME, 'DD-MON-YYYY')=TO_CHAR(SYSDATE, 'DD-MON-YYYY') group by TASK_NAME,START_TIME ");
//File file = new File("C:/purge_test/tr.txt");
// ResultSet rs=stmt.executeQuery("select TMS_TASK_LOG_ID,TASK_NAME,START_TIME,STATUS from TMS_TASK_LOG where TASK_NAME = 'purge_database' AND ROWNUM < = 1 order by 1 desc");
if(rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" ");
/*System.out.println(rs.getString(1)+" ");
System.out.println(rs.getString(2)+" ");
System.out.println(rs.getString(3)+" ");
//System.out.println(rs.getString(4)+" ");
Date d = new Date();
System.out.println("date "+d);*/
String fullstr =rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)+" ";
System.out.println("**********"+fullstr);
//__________________________
FileWriter fw = new FileWriter("C:/purge_test/foooooo.txt");
for (int i = 0; i < 10; i++) {
fw.write("something:\t"+ fullstr);
}
fw.close();
System.out.println("****00000******"+fullstr);
}
System.out.println("Done for store :"+store);
//step5 close the connection object
con.close();
}catch(Exception e){ System.out.println(e);}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
|
|
|
|
|
OUTPUT :
purge_database 16-AUG-2016 04:00:08 Task Initiated
**********purge_database 16-AUG-2016 04:00:08 Task Initiated
****00000******purge_database 16-AUG-2016 04:00:08 Task Initiated
Done for store :Test
purge_database 16-AUG-2016 04:00:15 Task Initiated
**********purge_database 16-AUG-2016 04:00:15 Task Initiated
****00000******purge_database 16-AUG-2016 04:00:15 Task Initiated
Done for store :store
This to be printed in a text file...
while running the above code...
only value of fullstr
purge_database 16-AUG-2016 04:00:15 Task Initiated
**********purge_database 16-AUG-2016 04:00:15 Task Initiated
is printed to a text file...
i want all the output of console to be writed in a text file
|
|
|
|
|
~You already posted this in QA; please do not post the same question in multiple forums.
|
|
|
|
|
Looking at the time-stamps, the QA question is the repost. This forum post is a repost of the one immediately below, which appears to be the original.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|