This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!

Ernesto Leyva

Ranch Hand
+ Follow
since Feb 23, 2006
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 Ernesto Leyva

what would be your favorite JS feature and what would be your least fav feature?
hello

I implemented the jquery sortable plugin to be able drag and drop list-items between two lists. I apply some styles to my list items like putting different background for each list. the issue is when I drag one item from list A to list B most of the time I see the dragged elements but every now and then when i start dragging the element disappear from the screen I can still drag it but I cannot see it and suddenly appears again when I drop it. The only i am able to see in those cases is the mouse pointer.

here is my code:

Note: the switched var tells me if the item changed from list A to B or vice versa!
Note2: in the same page I load EXTJS and jQuery but I am not triggering EXTJS events when dragging and the list items are plain
  • elements

    var switched, senderID;
    $CQ('#sni-selection .sni-selection-list').sortable({
    connectWith:'.sni-selection-list',
    start:function(e, ui){

    switched = false;
    senderID = '';
    },

    stop:function(e, ui){

    if (switched){

    so.selection.move(ui, senderID);
    }else{

    so.selection.drag(ui);
    }
    },
    receive:function(e, ui){

    senderID = ui.sender[0].id;
    switched=true;
    }

    });

Hi

if I delcare the interface XResult public like this:

public interface XResult {}

Now this line compiles

response = TVRunner.getResult().toString();

However the question remians.

Suppose the interface is declared in the default package like this:

interface XResult {
public Object getValue();
}

Why the code compiles with this line

response = TVRunner.getResult() + "";
13 years ago
Hello,

Someone knows why the java compiler throws the following error:

"toString() in java.lang.Object is not defined in a public class or interface; cannot be accessed from outside package"

I mean toString() is a public method from object so is there by default.

I am running JSDK 1.4.2 on windows xp



import com.company.*; => this is the import clause at the top of the program. The program lives in the default package.



String response = XRunner.getResult().toString(); ==> This is the line of the program that throws the compilation error.


this is the code in the package:

package com.company; ==>package declaration


public final class XRunner{ ==>public class so can be referenced


public static final XResult getResult(){ ==>Static method

}

}

interface XResult { ==> Result interface default access
public Object getValue();
}

Note that if I change the error line like follows:

String response = XRunner.getResult() + "";

The compiler does not complain and the program runs as expected.
I mean if the problem is interface XResult is not public why the second form compiles?

any ideas?

Thanks
13 years ago
Hello

Let say I have this code:

String x = "abc";

is there any problems if I do this:

if (x!=null && x=="abc") System.out.print("Hello World!");

what's the reason I should do this, if the first one work.

if (x!=null && x.equals("abc")) System.out.print("Hello World!");

thanks
14 years ago
Hello


...AJAX, in particular, the Javascript XMLHttpRequest method, is under the same restrictions as a Java applet. It may only make a request back to the server the page was downloaded from. So no, AJAX will not solve your problem....



You may want to check this property "document.domain = 'mydomain.com'"

We used the XMLHTTPRequest sometime ago and I remember at some point
we started getting security warnings that we solved using the property
above thru javascript when the html page was loaded. This worked for IE6
I am not sure for other browsers
15 years ago
IE does not fully support LiveConnect. However
if you declare public member vars and methods
in your applet you should be fine.

For instance
[code]
public class MyApplet extends Applet{

public String title

..... your code to set title

}

Then

<html>
<head>
<script>
function testF(){
alert(myapplet.title);
}
</script>
</head>
<body>
<OBJECT id="myapplet"
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="1" height="1">
<PARAM name="code" value="MyApplet.class">
</OBJECT>
</body>
</html>
15 years ago
thanks a lot I wish all good luck when
it gets your chance. I will keep an eye
on the forum.
Actually I must say without the Head First book I had not got such score
I think the book gave me a very good understanding of the concetps then
I had to sharpen this with additional material. Cogratulation to Bert, Katy and Bryan to write such a great and didactical book.
15 years ago
Hello Yesterday I took my SCWCD exam I passed with 91% I found if you read the Head First book is good enough to get around 70% but you really need to take a look into specs specially for the DD elements and check the JSP spec for the Standard Actions, EL and custom tags. If you do this you shoul get around 80%. Also I think it is a must download tomcat and do as much exemples as possible specially checking the JSP translated code for standar actions. This should make it for the 90%. Above that I think you need to be lucky or have a lot of experience in servlet and jsp.

But it was a great experience because beside servlet and jsp I revisit my basic concepts of java like, threads, collections, etc.. Reviewing the specification I learned more about xml schemas and xml namespaces I learned about patterns I am sure this will help me to see my programatic problems from different inshights. So beside the number there are a lot of hidden values when taking the exam.

Good luck to everybody.
15 years ago
Hello

This morning took the exam I got a 91 which is very good for me.
when I took the mock exam from the Head First book I got around 78%

The real exam focuses a lot in standar actions and EL they mix regular scriptlets with standar actions so you have to be careful about the scope an object is save when mixing this code. Also be careful about the
object type and the automatic or explicit casting needed when workin with attributes. when it comes about EL make sure you know the EL-implicit objetcs and when to use the [] and "." operators there are some triky questions on this. Also I got a lot of questions about the elements in the DD. Make sure you double check the spec about this and the directives <%@ %> as well. For the servlets make sure you really know the API check sendRedirect, sendError, RequestDispatcher, session and listeners. They ask me some questions about the patterns actually that was my weakest link only (66%)

Well thank you very much for all the answers you gave to my questions they really really help me in this exam. I wish you good luck and hope we see in SCBCD.

PD: Also review dynamic attributes.
I ran a test in Tomcat5.5

I created the following servlet:



then I put the web.xml as stated in this thread (two <servlet> elements) for the same servlet) and guess what I got two different screens so yes Tomcat did create two instances. Now I am trying to search in the specification to see if this is mentioned somewhere.
Yes

I ran the same test in Tomcat5.5. I created a simple tag
then I didn't put the <body-content> in the TLD then
I got an error in my web browser saying the value for
body-content JSP was invalid. So seems tomcat is doing
JSP the default but I belive this is tomcat specific only.

For tag-files you use the TAG directive and yes the default for
it should be "scriptless" this is inconsistence with the other
two tags simple and classic
Yes that's what I thought but in a mock exam
I got is vendor dependant because this option
is invalid for SimpleTags???
Acutally the point is to clarify if the container
will create two instances. I read in HJSC the container
will create only one instance of a servlet