Andrew Babaian

Greenhorn
+ Follow
since May 16, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Andrew Babaian

thanks for the help.
I'm interested in event handling, specifically the click event. The documentation says that Event.observer takes an element id or object.

http://wiki.script.aculo.us/scriptaculous/show/Event.observe

Can I pass an array of anchor elements as the object? I only want to handle click events of any link on the page.

Thanks

Andrew
I know there's plenty of examples and discusions of pagination through record sets out there, but I'm looking for some help on paginating through text. I have magazine text articles anywhere from 500 - 5000 words that the client would like to paginate across multiple jsp pages.

I've searched on pagination, but haven't seen anything that relates to my needs. Can anyone send me in the right direction for something like this?

Thanks

Andrew
19 years ago
JSP
wow, that helps. I just removed the entire Reading section and this works fine. I thought you need to read to do an append, but the boolean argument takes care of that.

thanks for the link to the tutorial, I'll check it out.

Andrew
20 years ago
My class and method seem to be working, but in the Tomcat server window, The IOException is thrown saying "Stream closed"

This exception was not thrown when I was passing a command line argument.

I packaged the class in web-inf\classes\beans dir and imported beans.* in the jsp page. Called CreateLog.LogIn(strLoginInfo) and the excepttion is thrown. Why is this happening now?
20 years ago

Originally posted by Andrew Babaian:
FileReader readFile = new FileReader(myFile);
BufferedReader bufferFile = new BufferedReader(readFile);
while(true){
strRead = bufferFile.readLine();
if (strRead == null){
logIn.print(args[0]);
readFile.close();
logIn.close();
System.exit(0);
}

//this line is not needed
logIn.println( "\r\n" + strRead);



I see, the last println is not needed.

Andrew
20 years ago
thanks. Are you saying I'm missing an association or that I'm not supposed to have an assocation between a Reader and writer

Andrew
20 years ago
I'm trying to create a daily log file of users logged in to a web app. (for now, I'm taking a comman line argument) I can't seem to loop through a BufferedReader. I keep rewrting over the first line of the log file.

It feels like I'm overlooking something simple, should the BufferedReader be saved off to String[]?

On a seperate note, is the Java Logging API better suited for these purposes?

thanks in advance?

Andrew

import java.util.*;
import java.text.*;
import java.io.*;

public class CreateLog {

public static void main(String[] args) {

try{
Date today = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String strToday = dateFormat.format(today);

String strPath = "C:/LocalRSB/logs";
File myDir = new File(strPath);
File myFile = new File(myDir, strToday + ".txt");
String[] strFiles = myDir.list();
String strRead = "";

FileWriter file = new FileWriter(myFile);
PrintWriter logIn = new PrintWriter(file);

for (int i=0; i < strFiles.length; i++){
if (!myFile.exists()) {
myFile.createNewFile();
}
}

FileReader readFile = new FileReader(myFile);
BufferedReader bufferFile = new BufferedReader(readFile);
while(true){
strRead = bufferFile.readLine();
if (strRead == null){
logIn.print(args[0]);
readFile.close();
logIn.close();
System.exit(0);
}
logIn.println( "\r\n" + strRead);
}
}
catch(IOException e){
System.out.println(e.toString());
}
}
}
20 years ago
I'm a little confused. I can compile and run:
public class test
{
public static void main(String[] args)
{
System.out.println("hello world!");
}
}
but I can compile, but can't run:
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("hello world!");
}
}
I get this exception:
Exception in thread "main" java.lang.NoSuchMethodError: main
I also can compile but can't run:
public class helloworld
{
public static void main(String[] args)
{
System.out.println("hello world!");
}
}
I get this exception:
Exception in thread "main" java.lang.NoClassDefFoundError: helloworld (wrong name: HelloWorld)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
What gives?
Thanks
Andrew
20 years ago
The exception and root cause is quite lengthy. Tomcat does not show me anything in the server window, but this is the report (500) returned:

HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: No data found
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:536)

root cause
javax.servlet.ServletException: No data found
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:497)
at org.apache.jsp.timeentryconfirm_jsp._jspService(timeentryconfirm_jsp.java:256)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:536)
[ December 16, 2003: Message edited by: Andrew Babaian ]
20 years ago
JSP

Originally posted by Tim Baker:
why are you treating that field as an Object in one line and then as a String in the other?
if it really is a String you don't need to cast it when using getString
String timeEntryID = rsLastEntry.getString("TimeEntryID");
and how do you know it isn't being put in the session?


I figured if I was getting an exception because of that line, and the page was not being returned then it wasn't going in the session. When I comment out the setAttribute, the page returns fine.
I see my object/string mistake. I originally did the cast because I thought I had wrote getObject, but then changed it becasue it was truly a string.
the code has changed to:
<td><%=rsLastEntry.getString("TimeEntryID")%>
<%
session.setAttribute("TimeEntryID", rsLastEntry.getString("TimeEntryID"));
%>
I'm still getting the "no data exception" though.
Thanks
Andrew
[ December 15, 2003: Message edited by: Andrew Babaian ]
[ December 15, 2003: Message edited by: Andrew Babaian ]
20 years ago
JSP
I have a JSP that get's a variable from the session.
The variable is used in a string SQL expression to return
results from a database.
<%@ page contentType="text/html; language="java" session="true" import="java.sql.*" import="java.text.*"%>
<%
String strEmployeeID = (String) session.getAttribute("EmployeeID");
String strSQL = "SELECT TimeEntryID, EmployeeID, ClientNumber, " +
"FROM qryTest " +
"WHERE [EmployeeID] = " + strEmployeeID + ";";
%>
I results return fine, but when I try add a new attribute to the session
I get a "no data found" exception:
<%-- line works fine --%>
<td><%=rsLastEntry.getObject("TimeEntryID")%></td>
<%-- doesn't work --%>
<%
//Want to put "TimeEntryID" in session
String timeEntryID = "";
timeEntryID = (String) rsLastEntry.getString("TimeEntryID");
session.setAttribute("TimeEntryID", timeEntryID);
%>
If I can pull the value of TimeEntryID from the request, why can't I add it to the session.
Thanks
Andrew
20 years ago
JSP
I also notice you can use the Date class of the java.sql package instead. For some reason I could not find this in the documentation.
Thanks again.
20 years ago


The data format is Date, and that simplifid way of writing it works. Thank you.
20 years ago
thanks for the help. it works now.
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
dateFormat.setLenient(false);
java.util.Date date = dateFormat.parse(rsLastTimeEntry.getString("Week ended"));
SimpleDateFormat shortDate = new SimpleDateFormat("MM/dd/yyyy");
shortDate.setLenient(false);
out.println("<TD>" + shortDate.format(date) + "</TD>");
-------------------
Andrew
21 years ago