jose chiramal

Ranch Hand
+ Follow
since Feb 12, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by jose chiramal

Code snippet :

Integer i1 = 1000;
Integer i2 = 1000;

if(i1 != i2)
System.out.println("different objects");
if(i1.equals(i2))
System.out.println("meaningfully equal");

Produces output :

different objects
meaningfully equal

However,

Integer i1 = 10;
Integer i2 = 10;

if(i1 == i2)
System.out.println("same objects");
if(i1.equals(i2))
System.out.println("meaningfully equal");

Produces output :

same objects
meaningfully equal

Could someone explain the output in both scenarios ?
12 years ago
Is there any alternative that I could use then since Date is deprecated ?

Also mapping those timezones which aren't in the (undocumented) list may not be feasible since we don't know the list of timezones that would be used.

Thanks.
12 years ago
I have tried with the below code snippet :




This works fine when the TimeZone is GMT or PST, but when i use IST , eg (08/06/2012 01:51 PM - 01:51 PM IST) or CET , eg (08/06/2012 07:54 AM - 07:55 AM CET) it gives me a java.lang.IllegalArgumentException

Any help would be appreciated.

Thanks.
12 years ago
Thanks for your posts.

Could someone please provide me a sample code where I would be able to sort the below data(ascending / descending). The sorting should happen based on the TimeZone where the program is running.The first question is if its possible to sort the time belonging to different TimeZones(eg GMT,PDT etc...all time zones used worlwide). I would like to sort based on the date and the start time(example for 08/02/2012 12:30 PM - 06:45 PM CET ; I would like to sort based on the date and the start time ie based on 08/02/2012 and 12:30pm CET) :

08/02/2012 12:30 PM - 06:45 PM CET
08/02/2012 12:30 PM - 06:45 PM GMT
08/02/2012 12:30 PM - 06:45 PM IST
etc..etc..

Any help with sample code would be much appreciated.

Thanks,
Jose
12 years ago
Hi,

I have date in the below format :

08/02/2012 06:30 PM - 06:45 PM PST
08/02/2012 12:30 PM - 06:45 PM CET

.. GMT and such other time zone.

Could you please help me in sorting these values ?

Am looking at sorting the date and the start time. eg(for the first one). 08/02/2012 06:30 PM PST

Kindly assist at the earliest.


I tried using something like this, but in vain :



String dateString1 = dateFormat.substring(0, 19); //dateFormat : 08/02/2012 06:30 PM - 06:45 PM PST
String dateString2 = dateFormat.substring(30, 34);
String dateString3 = dateString1 + dateString2;
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy, HH:mm:ss a z");
String date = sdf.format(new Date (dateString3)); // i get an exception here

Any help is much appreciated.

Thanks,
Jose
12 years ago
This is my jsp code (i have pasted only the required portion)


Javascript code :

var1=document.getElementById("adminPanel:adminForm:rptType"); // this gives me a HtmlTAbleObject
alert(var1.value); // gives me a null value here . i presume sthg wrong in the above statement..

Kindly advise how I can get the value of the radio button thats clicked from inside my javascript function.
Is it mandatory to use binding or value along with <h:selectOneRadio to get the button thats clicked..???
13 years ago
JSF
Also am using safari as my browser. So please let me know if that could be the issue and the fix to overcome the same. Thanks.
Here I have the button named rptType inside the form named adminForm which is inside the panel named adminPanel

document.getElementById("adminPanel:adminForm:rptType");
<htm:table id="htmtable1" border="0" width="100%" >

<htm:tr>

<htm:td width="60%" styleClass="lableStyleLeft">

<h:selectOneRadio id="rptType" layout="lineDirection" value="Admin_Agent_Report" styleClass="pr_boldInner" onclick="loginauditReportChk();">

<f:selectItem id ="rpttype1" itemLabel="Admin/Agent Report" itemValue="Admin_Agent_Report" />

<f:selectItem id ="rpttype2" itemLabel="Login Audit Report" itemValue="Login_Audit_Report" />

</h:selectOneRadio>

</htm:td>

<htm:td width="40%">

<h:outputText/>

</htm:td>

</htm:tr>

</htm:table>

I have the javascript function below



function loginauditReportChk(){

alert('from inside loginauditReportChk js');
var var1=document.getElementById("adminPanel:adminForm:rptType");
alert(var1 + " - " + var1.value);

}

The last alert above doesnt provide me the desired results ie. the element name and the value. It tells me that var1 is a HTMLTableObject and var1.value comes as undefined or null. Please assist on the below questinos :
1 . I read smwhere in this forum that the document is not yet created hence the issue...could someone please elaborate this point.
2. Am using tomcat to run the applciation. Am I missing any jars, if so what are they.

I read this statement regarding

Shallow copy: If a shallow copy is performed on obj-1 then it is copied but its contained objects
are not.

I did not understand this statememt , how can one object ahve other objects within it ?

Can i say an array of arrays is an example where we have objects within an object ?
14 years ago
--> where do cookies get stored ?

--> how does servlet ensure instance persistence ?

--> I noticed that getattribute method is present only in ServletRequest , but not present in HttpServletrequest. Why so, any reason for the same ?
14 years ago
When we say "load a servlet" what does it actually mean ?

- where exactly does the servlet get loaded - into the memory, or into the container ??
- also what are the methods that get called on the servlet. init method gets called for sure, what about the service method ? does loading a servlet mean that the servlet gets serviced as well ?
- also regarding the the load on start up tag in web.xml. Can we have two servlets with load on startup value as 1 ?
14 years ago
Can someone please clarify the difference between Page and PageContext impilcit objects in jsp ?

page : page is of class java.lang.Object,and it refers to instance of generated servlet. // what does this mean ?

PageContext : pageContext is of type javax.servlet.jsp.PageContext.

Am not able to get the difference between these both, please assist.
14 years ago
JSP
few doubts regarding servlets :

1. Can a servlet have a constructor ? - my answer is yes.
2. is it mandatory that i should override the doGet() and doPost() methods ? Can I have a servlet(user defined servlet) without doGet() and doPost() methods ?
3 Suppose I have a userdefined servlet that extends HttpServlet what are the methods that I mandatorily need to override in my user defined servlet ?
4. When do we use ServletResponse and when do we use HttpServletResponse. The methods like encodeURL, sendRedirect etc are present in HttpServletResponse but not in ServletResponse.
14 years ago
There are two ways of getting a requestDispatcher :

1. RequestDispatcher view = request.getRequestDispatcher("result.jsp");

Here i can also use RequestDispatcher view = request.getRequestDispatcher("/result.jsp");

2. RequestDispatcher view = getServletContext().getRequestDispatcher("/result.jsp");

Here can i use RequestDispatcher view = getServletContext().getRequestDispatcher("result.jsp") or would it give me an error..saying the location has to start from root ??;
14 years ago