Help coderanch get a
new server
by contributing to the fundraiser

Sunni srivastav

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

Recent posts by Sunni srivastav

I came across a code snippet which iterates over a map using its entry set and performs some action only if entry != null

As far as I know even if we don't enter anything in map this method returns an empty set and not a null set.
Even if I put {null,null} then the entry will be [null,null] employing an instance of set with these elements.



I have below question:
1. Under what scenario an entry in HashMap will it be NULL?
2. Is the check even valid ?
9 years ago
I can understand that you are trying to correlate Java with C/C++.

Let us try to do it then

Logically if there are two variables let it be "X" and "Y",then for your code there are two cases

Case 1: X and Y are two variables where each point to different memory location with same set of values.
Eg: X = 10 ,Memory location=6999(some random assumption)
Y=10 , Memory location=50000
Now if you make change to X it is reflected only for X and not for Y.

Case 2: If both are pointing to a value in same memory location.
Then if one is changed, the same is reflected for the other.


The primitive assignment operations falls under Case I.Hope this answers your questions.


Carry on with your java exploration the object/class reference concept will become cleared gradually.


9 years ago
In context of java "instance" means object.

When we create an object,we create it by using new keyword over its constructor.

Consider the below class:


Now if we are creating object of this class using the default constructor


and fetch the value for its members
then we get the default values

fruitName=Mango
fruitColor=Yellow

Now we go ahead and change these values using setters


After this the members become

fruitName=Apple
fruitColor=Red


After doing all these you serialize the object and then deserialize it.Now please go ahead and fetch the values you will get

fruitName=Apple
fruitColor=Red

implying that the object was persisted/stored and then the same object is reconstructed with the stored object info in the file which you specify during serialization.So the constructor is not called while doing all these.Hence its instance variables were not assigned the initial values.

Suggestion:Whenever you are reading anything try and implement it.Then the concept will become more clear.
12 years ago
found the mistake....


should be replaced by
I am reading jquery for dummies,and was trying to execute first example of the book:


But the alert box does not pop up when I load this page.Image appears on the page but not the dialog box...I don't know what am i doing wrong.
I want to find the location of an android phone using GPS.Currently I am developing using Eclipse IDE and its android plugin.
Came across code to do this GPS code

But when I am trying to execute it does not display the longitude and latitude even after setting it through Geo command as well through DDMS

The Code is as below:


On the emulator, it prints Provider not available which is I guess cause
here location is null...
Please help in fixing this...
12 years ago
@Rob and @jhon masco :Thanks to both of you...it worked both the ways..:)
12 years ago
JSP

Rob Spoor wrote:That would until you decide to move the JSP to a sub folder and forget to modify either the JSP or the servlet's URL mapping.



Rob could you please elaborate or provide me any link which could enlighten me over this discussion.Cause I would like to understand this mapping concept more..I think its the core of any web project...So any guidance would be highly appreciated.
12 years ago
JSP
I know this very basic but I guess I am doing something wrong in my implementation...so please help

Note:I am using eclipse IDE for my development

Project Name:Greeting


Servlet :GreetingServlet.java




index.jsp





and my web.xml






When i am deploying my project on apache tomcat in Eclipse I am getting "index.jsp" but my index.jsp does not redirect to GreetingServlet.java on submitting.



Error message is as follows:
HTTP Status 404 - /GreetingServlet

--------------------------------------------------------------------------------

type Status report

message /GreetingServlet

description The requested resource (/GreetingServlet) is not available.

12 years ago
JSP
Found this thread helpful
12 years ago

Christina Bremmerman wrote:Your If loop is setting it to true and then right after you are setting it to false.
Just remove the tnt=false line because that's what's resetting it back to false
or if you really want you could make the false into your else clause


Just writing the above in code so that it becomes clear to you...



If you want output based on whatever your if condition evaluates then make it as below
12 years ago
I assume that you are using JDBC statement to process your sql query.Then,from the resultset you can get the resultsetMetadata which contains all the info about it i.e. Table names,Column Names number of columns retrieved,etc.You can use its object to get whatever you need.For eg:


There is no need for a sql parser if ResultSetMetadata can fullfill you need..but it has one limitation as it will fetch table name related to each column...

James Boswell wrote:abhinav

You would need to parse the XSD file to pick out, at a minimum, the mandatory elements required in the XML file.

The JAXP tutorial may help you here: http://docs.oracle.com/javase/tutorial/jaxp/index.html

I do agree with Paul though. I see no reason why you would want to do this.



Thanks james,link provided by you really helped me..:)

James Boswell wrote:abhinav

You would need to parse the XSD file to pick out, at a minimum, the mandatory elements required in the XML file.

The JAXP tutorial may help you here: http://docs.oracle.com/javase/tutorial/jaxp/index.html

I do agree with Paul though. I see no reason why you would want to do this.


Thanks for link.

I want to do it cause I am working on something in which I have to know the depth of XML files.But I have only XSD files available and the depth of an XSD and XML is not same.

In case you all know any other way to determine the depth of XMl files conforming to a particular XSD then please tell me that also.But remember I have only XSDs available for this problem...

Paul Clapham wrote:Or to look at it the other way around: if there's no reason to do it, then there's no reason to help you to do it.

(And my record is still perfect: nobody has yet stated a reason for doing this.)


Thanks for the assistance.
Anyone else who knows how to do it.???Thanks in advance