Katie McCann

Ranch Hand
+ Follow
since Jul 24, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Katie McCann


OK, I think I understand why the above doesn't work. According to some documentation I found:
" Note that the use of this method does not halt the execution of any remaining scripts until the timeout has passed, it just schedules the expression or function for the specified time."
So the while loop keeps executing continually, not ever 1000 ms or whatever.
I'm getting skeptical if this is even going to be possible. Anyone know a workaround?
Hm... that's not working either. What i did was this:
function wait()
{
while (_userSelection==null)
{
getUserSelection();
alert("calling set Timeout");
setTimeout('getUserSelection()', 1000000);
}
}
function getUserSelection()
{
return _userSelection;
}

Even though I put a huge number of ms in the timeout argument, it doesn't seem to be working right- the alerts are popping up constantly (i threw them in there to see what was going on), and the function is hogging up all my CPU and eventually crashing the browser.
Any other ideas would be very much appreciated. Thanks!

Ok, I am desperate. Essentially, I need to be able to do this:
while (_myVar ==null)
{
sleep(100);
}
Basically, I don't want the current function to continue until the _myVar var has been set by another function (that is called by a DHTML layer that contains a form where the user makes a choice). I am aware that there is no sleep function in javascript, and I've tried working with setTimeOut() like this, but it doesn't work, as it seems that setTimeOut launches a new thread, so the function exits anyway:
function wait()
{
while (_userSelection ==null)
{
setTimeOut('wait();', 100);
}
//each wait call exits here anyway
}
Any ideas? Greatly appreciated!

Thanks for the help- got it working. Seems that it was just the fact that I forgot to close the connection (dumb oversight on my part) that was doing it. D'oh.
Hi. I'm connecting to an Access database via JDBC- ODBC. I can read data and add rows just fine. But I can't delete a row. I"ve tried 2 ways:
#1:
String sql= "select * from data where state=? and school=? and lastname=? and firstname=? ";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection( "jdbc:odbc:profsaccessdata" );
PreparedStatement st = con.prepareStatement(sql);
st.setString(1, state);
st.setString(2, school);
st.setString(3, lastName);
st.setString(4, firstName);
ResultSet rs= st.executeQuery();
while (rs.next())
{
rs.deleteRow();
break ;
}
This gives this error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Invalid cursor position; no keyset defined
___________
#2 (note the "delete" in the SQL):
String sql= "Delete from data where state=? and school=? and lastname=? and firstname=? ";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection( "jdbc:odbc:profsaccessdata" );
PreparedStatement st = con.prepareStatement(sql);
st.setString(1, state);
st.setString(2, school);
st.setString(3, lastName);
st.setString(4, firstName);
int updated= st.executeUpdate();
System.out.println(updated);
This way, if I give it paramaters I know exist in the database, it will print out "1" in my system.out.println statemnet at the end, which according to the API documentation implies that Row #1 of the resultset was deleted (if I give it bad parameters, it prints out 0, as expected). But the data is still in my Access database.
Any ideas??
Thanks in advance.
Katie

Get your session like this:
HttpSession session= request.getSession(false);
Giving it the "false" flag will *NOT* create a new session if one is not found, so then you can just do:
if (session !=null)
{
etc...
}
22 years ago

Oh, and BTW, it works just fine in JRun3 (catching the exception- though not the SErvletException, but it does a allaire.jrun.JRunServletException). Unfortunately, we still deploy on 2.3
22 years ago
P.S.- I'm running my code with Jrun 2.3 if it makes any difference.
22 years ago

I'm using a RequestDispatcher to forward to a JSP page. In my code, I need to be able to handle errors if the page that it tries to forward to a page that doesn't exist in order to avoid seeing:
javax.servlet.ServletException: The page '/myapp/mydir/vehicleChange1.jsp' does not exist.
in the browser window (the path to the page is determined at runtime based on some input parameters). Anyway, for some reason I am having trouble with this. I've tried 2 ways:
1. I've tried catching the ServletException in the servlet. Doesn't work. I can't find any documentation about this, but I'm guessing that by the time the exception is thrown, my servlet has lost control.
2. On Sun's website (http://java.sun.com/docs/books/tutorial/servlets/communication/request-dispatcher.html), they claim that when you do:
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(page);
the RequestDispatcher will be null if the page doesn't exist. They even show a specific example where the check for null. I tried that, again, didn't work. In the simplest form:
if (dispatcher==null)
{
System.out.println("dispatcher null");
}
and got nothing.
Ideas, anyone? Thanks in advance!
22 years ago
No. I had originally tried using <xsl:copy-of .../> with the embedded HTML *NOT* stored as CDATA (just a regular element) but it still didn't work in JDOM.
About 15 min. after posting the original message, I solved my own problem. It was something that the JDOM XMLOutputter class file was doing. There is a escapeElementEntities(String st) method, and I had to comment out the following lines:
/*
case '<' :
stEntity = "<";
break;
case '>' :
stEntity = ">";
break;
*/
Not an elegant solution, but it worked.
Thanks.
Hi all,
I'm desperately seeking help with a problem I'm having with an XSLT transformation using JDom. I'm pretty new to Jdom/XSLT/etc. and I'm not really sure if the problem is JDOM or XALAN related. Nonetheless, here goes:
One of my XML elements has HTML text in it. I'm storing it as CDATA:
<FullButton><![CDATA[<input type ="hidden" name="year" value="2001"><input type ="hidden" name="make" value="Volvo"><input type ="hidden" name="model" value="S40"><input type ="hidden" name="trim" value="SE 4dr Sedan (1.9L 4cyl Turbo 5A)">]]></FullButton>
After I do the transformation, the "<" and ">" are all transformed into < and >, screwing up the html formatting. I have spent all morning trying various fixes that I have found on various message boards, including:
* using disable-output-esacping="yes"- this just causes my resulting HTML doc to have this declartion surrounding the appropriate text: <?javax.xml.transform.disable-output-escaping?>
* using <xsl:copy-of .../> instead of <xsl:value-of>
* inserting a cdata-section-elements="//styleinfo/FullButton" element into the <xsl:output .../> declaration.
I can't get anything to work. I was searching around on apache's Xalan site, and it looks like Xalan *SHOULD* process this correctly. So I'm wondering if it's something with JDom? For the most part, I am using the most recent Jdom .java files from the CVS (as opposed to what's in the build 6 .jar file)- and I'm also using xalan.jar etc. from the Jdom repository.
Any advice is greatly appreciated!
Katie
Thanks for the suggestion. The problem is, I need to do the check multiple times (for each "car" in my XML doc), but only execute the "do a bunch of stuff here" block once (or none- but not "for each"). Basically, I need to do something like this:
<xsl:for-each select="//styleinfo/car">
<xsl:if test="starts-with('/BrochureUrl', 'NA') and starts-with('/InfoUrl', 'NA') and ...">
</xsl:for-each>
... DO A BUNCH OF STUFF HERE...
</xsl:if>
But I'm pretty sure I can't nest the tags like that above. I hope I explained it clearly. Need to check for a condition in every "car", then if the condition holds, execute the "bunch of stuff" once.
Thanks for any suggestions.
Hi. Having some troubles with Xpath/XSL syntax again. Basically what I need to do is check a bunch of conditions, and only if they are all true, enter into a block.
Here's what I have:
<xsl:variable name="hasAds" select="yes"> </xsl:variable>
<xsl:for-each select="//styleinfo/car">

<xsl:if test="starts-with('/BrochureUrl', 'NA')">
<xsl:if test="starts-with('/InfoUrl', 'NA')">
<xsl:if test="starts-with('/SpecialUrl', 'NA')">
<xsl:if test="starts-with('/OfferUrl', 'NA')">
<xsl:if test="starts-with('/VideoUrl', 'NA')">
<xsl:variable name="hasAds" select="no"></xsl:variable>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:for-each>
<xsl:if test="starts-with('$hasAds', 'yes')">
... DO A BUNCH OF STUFF HERE...
</xsl:if>
I'm trying to create a variable called "hasAds" and set it to yes by default. If I go through that first set of <xsl:if> statments, I want the variable to be set to no. If, when it reaches this line:<xsl:if test="starts-with('$hasAds', 'yes')"> I want to enter that block. Basically, it seems that no matter what, I am never entering into the last <xsl:if> block (where I wrote "do a bunch of stuff here"), even when I know I should be.
Can anyone help out with the syntax? Thanks so much!

Thanks so much for the quick reply. Got it working (that part, at least- I'm sure I'll be back with more questions!)
Hi. I'm brand new to XSLT/XPATH and am stuck on what I'm sure is a really basic question. I need to do something like the following:
<a href="<xsl:value-of select="Picture"/>"> <img src="<xsl:value-of select="Picture"/>" border="0" width="130" alt="Vehicle"/>
Basically, I'm trying to create an href with a value that is stored in the source XML file. Just can't quite get the syntax right.
If I try to process it as above, I get the following error:
org.xml.sax.SAXParseException: Use "<" for "<" in attribute values.
But if I try subsituting "<" for the "<", I get an error saying something about whitespace being required before an attribute.
Anyway, can someone help me with the syntax?
Thanks in advance!
Katie