Comparator for TreeMap Integer[], Double

Hi all,
I'm trying to write a compartor for a TreeMap<Integer[], Double>. The Integer[] has always two entries and [x,y] should be equal to [y,x].
This is my code:
TreeMap<Integer[], Double> t = new TreeMap<Integer[], Double>(new Comparator(){
            public int compare(Object o1, Object o2) {
                Integer[] i1 = (Integer[]) o1;
                Integer[] i2 = (Integer[]) o2;
                if (i1[0].equals(i2[0]) && i1[1].equals(i2[1]))
                    return 0;
                if (!i1[0].equals(i2[0]))
                    return i1[0].compareTo(i2[0]);
                return i1[1].compareTo(i2[1]);
        });However, after inserting two elements like
t.put(new Integer[]{1,2}, 0.1);
t.put(new Integer[]{2,1}, 0.2);, the TreeMap contains these two elements instead of just one.
Is there an error in my Comparator?
Regards,
Andreas

the two elements are inside your map because their keys new Integer[]{1,2} and new Integer[]{2,1} are different, so they represent different values.
To make this simpler, one possibility is to create a wrapper class for these two integers, and override equals()

Similar Messages

  • Any simple example for comparator for treemap

    I have a treemap collection stored some data like
    a:4
    b:7
    c:5
    d:7
    e:1
    f:3
    The Treemap helped me to sort by key value like above.
    But what I want is sort by value , it should be like this
    b:7
    d:7
    c:5
    a:4
    f:3
    e:1
    I know comparator object can help me about the sorting mechanism in treemap, it is used like
    comp is comparator
    TreeMap tm = new TreeMap(comp)
    but I don't know how to construct this comparator object to help me sort by value.
    Any one can help me here??
    Thank you

    Here's a sample that demonstrates the issue. Note that when you run this that the comparator class never sees the data items (in this case 'a' - 'f'), only the numbers.
    Also notice that both sets that are returned (keySet and entrySet) are appropriately sorted.
    Finally, it is interesting to note that it looks like the TreeMap.get() method walks the tree to find the entry (no surprise), but the entrySet method returns both the keys and data in one shot. This implies that there may be a performance blip gained by asking for the entrySet and getting the values that way, rather than the first technique using the keySet and get().
    import java.util.*;
    public class x
         public static void main(String args[])
              TreeMap t = new TreeMap(new Comparator() {
                   public int compare(Object o1, Object o2) {
                        Comparable c1 = (Comparable) o1;
                        Comparable c2 = (Comparable) o2;
                        System.out.println("Comparing " + c1 + " - " + c2);
                        return c1.compareTo(c2);
                   public boolean equals(Object o) {
                        return false;
              String s;
              t.put("1", "f");
              t.put("2", "e");
              t.put("3", "d");
              t.put("4", "c");
              t.put("5", "b");
              t.put("6", "a");
              Iterator i;
              Set keys = t.keySet();
              i = keys.iterator();
              while(i.hasNext()) {
                   s = (String)i.next();
                   System.out.println(s + " - " + t.get(s));
              Set entries = t.entrySet();
              i = entries.iterator();
              while(i.hasNext()) {
                   System.out.println(i.next());

  • Comparator and treemap

    Hi
    I have treemap of integer as key and list as value which is giving results
    (2,email)
    (1,dfg)
    (4,dfgh).
    But I have to show result in descending order sorted by key of integer
    like (4,dfgh)
    2,email
    1,dfg
    how to do it.comparator used but not worked

    Hi Rashmi,
    what ever the code sample posted by you is working for me. please check this
    public class TreeMapSorting
         public static void main(String[] args)
              TreeMap<Integer,Object > ab1= new TreeMap<Integer,Object>();
              ab1.put(5, "sometext5");
              ab1.put(3, "sometext3");
              ab1.put(4, "sometext4");
              ab1.put(2, "sometext2");
              TreeMap<Integer,Object > tm2= new TreeMap<Integer,Object>(new Decreasin());
              tm2.putAll(ab1);
              System.out.println(tm2);
    class Decreasin implements Comparator<Integer>{
         public int compare(Integer i2,Integer i1){
         return i1.compareTo(i2);
    }Edited by: sri06 on Aug 12, 2008 7:28 AM

  • Cannot determine comparator for Sortfield

    I have a DataGrid that gets its data from an HttpService. If
    the first row of the data from the http request has a null value
    for a given field, I get the "Cannot determine comparator for
    Sortfield" error.
    I think the simplest workaround would be to specify the data
    type for each DataGridColumn. I see that the DataGridColumn objects
    can have a sortCompareFunction. I don't want to write my own custom
    comparators. I assume that the built-in comparators will do just
    fine.
    Suppose my MXML code looks something like this...
    <mx:DataGrid>
    <mx:columns>
    <mx:DataGridColumn headerText="My String"
    dataField="name" sortCompareFunction="???"/>
    <mx:DataGridColumn headerText="My Integer" dataField="ss"
    sortCompareFunction="???"/>
    <mx:DataGridColumn headerText="My Float" dataField="gpa"
    sortCompareFunction="???"/>
    <mx:DataGridColumn headerText="My Date"
    dataField="birthdate" sortCompareFunction="???"/>
    </mx:columns>
    </mx:DataGrid>
    What values would I use for the sortCompareFunctions in order
    to use the built-in comparators for the string, int, float and date
    types, respectively?

    One trick that I've used in the past (which wont really give
    you type specific ability) is to check the returned data prior to
    assigning it as a dataProvider. In my case the data is xml based
    son I don't get nodes, but possible missing elements all together.
    I check for their existance for each row (in your case test for
    null) then assign a default value (-1 for int, 6/6/2006 for date
    etc...). After populating the 'voids' in my data I assign it as the
    dataProvider in ActionScript.
    To get more type specifc, you may want to look into using a
    data model and check out the validator classes.

  • NullPointerException while updating a TreeMap Integer, Integer

    Dear All,
    I have a strange problem updating an empty TreeMap datastructure.
    I am trying to create a TreeMap map and put key-value pairs into it. It gives me a NullPointerException at the line -- if(!quals.containsKey(bq)){
    I am checking if the int variable is present in the keys of quals (TreeMap) and then updating accordingly.
    The snippet follows:
    public class Test{
    private TreeMap<Integer, Integer> quals;
    public void Test(){
    this.quals = new TreeMap<>();
    public static void void main(){
    String qual = "-)(*(%"'%.--)&./,*,&#.,'')+/-///+/)/,)/,)-/.//.+-..&)##";
    for(int i = 0; i < qual.length(); ++i){
    // deriving int value of a char
    int bq = qual.charAt(i);
    if(!quals.containsKey(bq)){
    quals.put(new Integer(bq), 1);
    else{
    int count = quals.get(bq);
    quals.put( new Integer(bq), ++count);
    }

    Welcome to the forum.
    please read this to make better posts: https://wikis.oracle.com/display/Forums/Forums+FAQ
    I'd say your code does not compile at all.
    Because you cannot acces the non static variable <tt>quals</tt> from the static method <tt>main</tt>. But maybe you forgot to type the static key word in your line 2 in this post?
    If so:
    you initialize the reference <tt>quals</tt> in the constructor (wich BTW is a bad practice). But since you do not create an Object of that class your reference never points to an actial map but to <b>null</b>.
    So the NPE you're facing is not strange at all... ;o)
    bye
    TPD

  • Comparator for Line2D and Point2D

    I'm trying to port a line intersection algorithm from using my own classes Point andd Line to using Point2D and Line2D.
    In the program, the line segments are read in from a file as x1,y1,x2,y2, added to an ArrayList points and an ArrayList lines. For the algorithm to work, the points need to be sorted on x, then on y order. The lines need to be sorted on y, then on x order. This is done with Collections.sort(points) and Collections.sort(lines). I managed to do this by "implements Comaparable" for my classes Point and Line, and by adding a compareTo method in each class:
    // Method for lexicographic sorting of lines on y
    public int compareTo (Object line){
    int result = lyf.compareTo(((Line)line).lyf);
    return result == 0 ? lxf.compareTo(((Line)line).lxf):result;
    // lyf,lxf = Float of left y and x respectively
    // Method for lexicographic lsorting of points on x
    public int compareTo (Object point){
    int result = xf.compareTo(((Point)point).xf);
    return result == 0 ? yf.compareTo(((Point)point).yf):result;
    // yf,xf = Float of y and x respectively
    Now, how do I port this to Line2D and Point2D ??
    I assume that I have to create two Comparator classes for sorting Line2D and Point2D objects, so that I can apply Collections.sort(List list, Comparator c).
    However, I cannot seem to make my code compile. Can anybody make an easy to understand example?

    I actually found the solution myself:
    //Comparator for points
    import java.util.*;
    import java.awt.geom.*;
    public class PointComp implements Comparator {
    public int compare(Object o1, Object o2) {
    Point2D.Double p1 = (Point2D.Double)o1;
    Point2D.Double p2 = (Point2D.Double)o2;
    Double x1d= new Double(((Point2D.Double)p1).x);
    Double x2d= new Double(((Point2D.Double)p2).x);
    return x1d.compareTo(x2d);
    //Comparator for lines
    import java.util.*;
    import java.awt.geom.*;
    public class LineComp implements Comparator{
    public int compare(Object o1, Object o2) {
    Line2D.Double line1 = (Line2D.Double)o1;
    Line2D.Double line2 = (Line2D.Double)o2;
    Double y1d= new Double(((Line2D.Double)line1).y1);
    Double y2d= new Double(((Line2D.Double)line2).y1);
    return y1d.compareTo(y2d);
    //Sort points in ArrayList points
    Collections.sort(points, new PointComp());
    // Sort segments in ArrayList lines
    Collections.sort(lines, new LineComp());

  • ArrayComparator For TreeMap Java 1.5

    Hi, I have a class like:
    public class TreeIndex extends TreeMap<Object[], HashSet<IRecord>>
    As you can see the Index uses an array of objects as the key, so I need to have a compare method looks like:
    public Comparator<Object[]> comparator()
    return
    new Comparator<Object[]>()
    public int compare(Object[] as, Object[] bs)
    System.out.println("compare two keys!");
    int length = Math.min(as.length, bs.length);
    int result = 0;
    for (int j =0; result==0 && j<length; j++)
    result = comp.get(j).compare(as[j], bs[j]);
    return result!=0 ? result : (as.length - bs.length);
    /* even these lines below wont work
    return
    new Comparator<Object[]>()
    public int compare(Object[]as, Object[]bs)
    {return 1;};
    The comp is a field that finds the appropriate Comparator for diffferent object.
    The program compiles but throws a ClassCastException saying that key cannot be compared with the keys currently in the map. I believe there is something wrong in the compare() after a thoughtful debugging but I cannot see anything wrong with it, could anyone give me soem suggestions please?

    below is a Exception message
    Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object;
    at java.util.TreeMap.compare(Unknown Source)
    at java.util.TreeMap.getEntry(Unknown Source)
    at java.util.TreeMap.containsKey(Unknown Source)
    at TreeIndex.<init>(TreeIndex.java:54)
    at ArrayRelation.setIndex(ArrayRelation.java:192)
    at rdbo2.main(rdbo2.java:61)

  • [svn] 1751: Bug: BLZ-174 - MessageClient.testMessage() is incorrectly doing a string compare for the subtopic header of an inbound message against the subtopic value (which may contain wildcards) that the Consumer is using.

    Revision: 1751
    Author: [email protected]
    Date: 2008-05-15 14:21:43 -0700 (Thu, 15 May 2008)
    Log Message:
    Bug: BLZ-174 - MessageClient.testMessage() is incorrectly doing a string compare for the subtopic header of an inbound message against the subtopic value (which may contain wildcards) that the Consumer is using.
    QA: No - customer verified the fix.
    Doc: No
    Ticket Links:
    http://bugs.adobe.com/jira/browse/BLZ-174
    Modified Paths:
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/MessageClient.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/services/MessageService.java

    If you create a metadatatype with a single metdata block, and you reference that in your vm/cm cell attribute using a *one* based index, Excel seems to see the link and it honors it when saving the spreadsheet.
    So, I ended up with something like:
    <c ... cm="1"/> (I'm dealing with cell metadata, but the concept is equivalente to value metadata)
    <metadataTypes count="1">
      <metadataType name="MyMetaType" .../>
    </metadataTypes>
    <futureMetadata count="1" name="MyMetaType">
      <bk>
        <extLst><ext
    uri="http://example" xmlns:x="http://example"><x:val>87</x:val></ext></extLst>
      </bk>
    </futureMetadata>
    <cellMetadata count="1">
      <bk><rc
    t="1" v="0"/></bk> <!-- this is what gets referenced as cm=1 on the cell -->
    </cellMetadata>
    Hope this helps. 

  • Use a variable for the integer in Fmt offset modifier

    I'm trying to pluck values out of a long array of comma separated string
    values.
    I'm doing this within a loop and would like to use the loop interation to
    point to the starting point in the array.
    Here's what I have working so far:
    Fmt (scratch,"%s<%s[i0t44]",transmitBuf);
    Works great.
    Now if I go in and change i0 to i3 then my modifier doesn't start looking
    for a comma "," until after the 3rd character. Still working great. However....
    If I try to use an integer called "loop" instead of the literal offset
    value it blows up:
    Fmt (scratch,"%s<%s[iloopt44]",transmitBuf);
    Is there a way that I can use a variable for the integer portion of the
    offset modifer?
    Thanks All!

    Hi Roberto
    Thank you. I actually need to use a symbolic value for the interger section of the modifer vs. the specifier.
    So, in my example:
    Fmt (scratch,"%s<%s[i0t44]",transmitBuf); 
    I want to make the following substitution (Assume z=0)
    Fmt (scratch,"%s<%s[izt44]",transmitBuf);
    Some background...
    I'm looking to loop index through a long CSV string array (transmitBuf) that looks like this:
    1,PEEP,7,6,,,21,20,
    So on my first loop when I use the following:
    Fmt (scratch,"%s<%s[i0t44]",transmitBuf); 
    scratch = "1"
    ... Perfect. I now do a string length of scratch (which equals 1)
    and add 1 to it, I'm ready for my next loop which would
    literally read like this:
    Fmt (scratch,"%s<%s[i2t44]",transmitBuf); 
    However, I want to put this inside a loop, so I would like to
    increment a variable (++z) and use the following:
    Fmt (scratch,"%s<%s[izt44]",transmitBuf); ---- Ka-Boom!
    So it's the use of the variable in the modifer that blows up
    the Fmt command.
    appreciate any thoughts...
    Thanks
    Mark

  • Windows 7 Comparability for SHA-256 (Code Signing)

    Dear All
       I want to know when the update for windows 7 (SHA-256 Code Signing Comparability -- for Kernel driver) will be available?

    Hi,
    I'm not sure whether you know this update KB 2949927, Microsoft is announcing the availability of an update for all supported editions of Windows 7 and Windows Server 2008 R2 to add support for SHA-2 signing and verification functionality.
    http://support.microsoft.com/kb/2949927
    Microsoft Security Advisory 2949927
    https://technet.microsoft.com/en-us/library/security/2949927.aspx
    This blog can also be helpful
    Microsoft Security Advisory 2949927
    http://blogs.technet.com/b/pki/archive/2010/09/30/sha2-and-windows.aspx
    Yolanda Zhu
    TechNet Community Support

  • Specify a comparator for property of type date

    Hi,
    In help.sap.com (http://help.sap.com/saphelp_nw70/helpdata/en/cc/f4e77ddef1244380b06fee5f8b892a/frameset.htm) I found the possibility to change the initial selected comparator for properties of the type date.
    Unfortunately the user can still change the comparator in the search option if I set a comparator in the search option set.
    I would like to know if it is possible to set a fixed comparator for a predefined property defined as ‘date’.
    Thanks an regards,
    Marco

    for example:
    javax.jcr.Session session = resourceResolver.adaptTo(Session.class);
    String parentPath = "/content/blah"; // or whatever your parent path is
    String nodetype = "nt:unstructured"; // or whatever other node type you require
    Calendar calendar = Calendar.getInstance(); // or whatever date
    Node node = session.getNode(parentPath).addNode("nodename", nodetype);
    node.setProperty("myproperty", calendar);
    session.save();

  • Two questions:  how do Skype and iChat compare for group video?  quality, reliability, cost, etc are important.  2) Is my MobileMe ID what I need to use in the window in making an iChat buddy?  It only says AIM above the window, online tutorial differs.

    Two questions:  1) How do Skype and iChat compare for group video?  Quality, reliability, cost, etc are important.  2) Is my MobileMe ID what I need to input in the window in making an iChat buddy?  It only says AIM above the window, online tutorial differs, saying MobileMe, AIM, GoogleTalk (Jabber) all work. Thnx

    Hi,
    IChat uses better Video Compression than Skype does.
    On a top flight Mac you can send a 640 X 480 pixel frame up to 30 frames a sec.
    Skype can't match this.
    iChat in Video is Peer to Peer. (you can actually Log out of the Buddy list)
    Skype seems to borrow something from everyone's bandwidth to make connections.
    What do you mean by Business account Tracking ?
    iChat Adds (or can add) the First Name, Last Name of your Buddies and create an Address Book Entry
    Whether you mark those cards connected with a  company is up to you.
    (I have heard of issues with earlier version of iChat and the Address Book that "saw" the Company Name as the part of the Name and linking several Screen Names to the one name
    Audio on a Mac using Skype tend to be the same as the streaming needs are less.
    However you have to rely on any PCs audio abilities from PCs which may not be to the same standard.
    Mac to PCs in iChat and AIM can be difficult though.  (It should work but it rarely as simple as Plug and go)
    Skype may suit your needs better on ocassions.
    9:11 PM      Thursday; May 5, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.7)
    , Mac OS X (10.6.7),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • [svn:fx-trunk] 11642: Simple fix for non-integer translations by first multiplying to twips before casting to int .

    Revision: 11642
    Author:   [email protected]
    Date:     2009-11-10 19:40:31 -0800 (Tue, 10 Nov 2009)
    Log Message:
    Simple fix for non-integer translations by first multiplying to twips before casting to int.
    QE notes: Please test non-integer translations in FXG.
    Doc notes: N/A
    Bugs:
    SDK-24110 - Drawing of compiled FXG items is off by half a pixel
    Reviewer: Peter DeHaan
    Tests run: Checkintests, Bug test case
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24110
    Modified Paths:
        flex/sdk/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/types/FXGMatrix.java

    i dont know why you are so mean i just asked which
    wrongs i had wrong
    anyway im done with thoseSo, the questions have 4 alternative answers. We tell you which questions you got wrong. This eleminates one of
    the alternatives, leaving 3 choices. Usually in most mutlichoice questions 1 choice is obviously incorrect,
    leaving 2 choices. One of those you have probably already discarded when you initially made your incorrect chocie
    thus leaving 1 alternative. Congratulations you just 100% on your test. I don't think so. Go read your book or notes or
    whatever you have because all the answers will be in there. The teacher will not ask you a question on a subject
    you have no prior knowledge of.

  • Failure migrating wiki to Mountain Lion Server with wikiadmin, value is out of range for type integer

    We are trying to migrate our 10.6.8 wikis from the OS X Server to our new Mountain Lion OS X Server.  I am using "wikiadmin migration -r <collaboration directory> -g <wiki name>" to migrate each wiki individually. We have about 30 wikis in the old server, three of which fail to migrate, all with the same problem (below). The process runs successfully for a while, but ultimately fails and rolls back the transaction. It appears there is some problem trying to generate a unique filename, perhaps for some of the uploaded files?
    Has anyone else seen this error? large amount of pages, content, and attachments in these wikis and just recreating them in the new server would be a monumental task. Some of these attachments include videos and other large files, not sure if that might contribute to the problem.
    === wikiadmin migrate output log ===
    Aug 29 13:25:11 gslcwiki.local wikiadmin[54032] <Debug>: [PGCConnection:233 7e7e1180 +0ms] Executing query [INSERT INTO entity (uid, tiny_id, entity_type_fk, short_name, long_name, description, create_time, update_time, createdby_user_fk, updatedby_user_fk, ownedby_uid_fk, owner_entity_type_fk, is_hidden) (SELECT uid, tiny_id, entity_type_fk, short_name, long_name, description, create_time, update_time, createdby_user_fk, updatedby_user_fk, ownedby_uid_fk, owner_entity_type_fk, is_hidden FROM master_entity_scratch_20120829T132314 WHERE entity_type_fk='com.apple.entity.File')]
    Aug 29 13:25:11 gslcwiki.local wikiadmin[54032] <Debug>: [PGCConnection:181 7e7e1180 +151ms] Query result is [PGRES_FATAL_ERROR] rows returned=0/updated=
    Aug 29 13:25:11 gslcwiki.local wikiadmin[54032] <Error>: [PGCConnection:148 7e7e1180 +0ms] Error in TXN: Error executing query [INSERT INTO entity (uid, tiny_id, entity_type_fk, short_name, long_name, description, create_time, update_time, createdby_user_fk, updatedby_user_fk, ownedby_uid_fk, owner_entity_type_fk, is_hidden) (SELECT uid, tiny_id, entity_type_fk, short_name, long_name, description, create_time, update_time, createdby_user_fk, updatedby_user_fk, ownedby_uid_fk, owner_entity_type_fk, is_hidden FROM master_entity_scratch_20120829T132314 WHERE entity_type_fk='com.apple.entity.File')]: ERROR:  value "109120715161" is out of range for type integer
              CONTEXT:  PL/pgSQL function "uniquify_filename" line 7 at RETURN
              PL/pgSQL function "trg_update_entity_filename" line 23 at assignment
                        0   CoreFoundation                      0x00007fff93b67716 __exceptionPreprocess + 198
                        1   libobjc.A.dylib                     0x00007fff95aaf470 objc_exception_throw + 43
                        2   PostgreSQLClient                    0x00000001026ff9ae -[PGCConnection checkResultOK:forSQL:] + 360
                        3   PostgreSQLClient                    0x00000001026ffec3 -[PGCConnection executeQuery:] + 223
                        4   wikiadmin                           0x000000010269d586 wikiadmin + 66950
                        5   PostgreSQLClient                    0x00000001026ff5f7 -[PGCConnection transactionInBlock:onError:] + 147
                        6   wikiadmin                           0x000000010269cd86 wikiadmin + 64902
                        7   wikiadmin                           0x00000001026a025d wikiadmin + 78429
                        8   wikiadmin                           0x00000001026924c8 wikiadmin + 21704
                        9   libdyld.dylib                       0x00007fff912857e1 start + 0
                        10  ???                                 0x0000000000000006 0x0 + 6
    Aug 29 13:25:11 gslcwiki.local wikiadmin[54032] <Debug>: [PGCConnection:320 7e7e1180 +0ms] Executing update [ROLLBACK]

    Okay, so a little more detail for you…
    If I can manage to restart the server without the wiki service on, everything else seems to work fine (including the web service running the default home page) and "serveradmin fullstatus wiki" will report that the service is stopped.
    But as soon as I try to start the wiki service, it never finishes, and it prevents the web service from working properly anymore. i.e. I get a 502 Proxy Error instead of the OS X Server default home page. It's after the attempted wiki start that "serveradmin fullstatus wiki" starts to give the
    serveradmin[2373:707] outstanding requests are: (
            Command = getState;
            Module = "servermgr_wiki";
            Timestamp = "2012-10-25 16:22:15 +0000";
    error. And then I can't stop the wiki service - even "serveradmin stop wiki" gives the same "outstanding requests" message.
    This time I tried to stop the wiki from Server app and I got this error:
    An error occurred on the server while processing a command.
    The error occurred while processing a command of type 'getState' in plug-in 'servermgr_wiki'.
    If it's helpful at all, I've notice the following in my log files that seem related, but I have no idea how to fix - it almost seems lie the migration of the wiki failed from 10.7 to 10.8:
    collabd[767]: [CSConnectionPool:141 6a92000 +14027ms] Schema is STILL out of date (14 < 69) after launching wikiadmin, update failed! collabd will refuse to run until this is fixed.
    I'm really pulling my hair out over here, and have no idea what to try next?
    Anyone have any suggestions?
    Thank you!

  • Assigning value for an integer

    i'm having two jsp pages. i pass value from one jsp page to another jsp.
    when i try to assign value for an integer, it is taking the default value. it is not taking the value what i assign. for string its taking correctly.
    this is the query string.
    document.book.action="cis1.jsp?lstr_bname=<%=lstr_bname%&lint_mss=<%=lint_mss%">
    here for lstr_bname it is taking the value. but not the case for lint_mss.(taking default value).

    Try this
    document.book.action="cis1.jsp?lstr_bname=<%=lstr_bname%&lint_mss=<%=Integer.toString(lint_mss)%">
    Bye

Maybe you are looking for