peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

As you named the JprogressBar as current
Change the following in code also,Hope it works!

UIManager.put("current.selectionBackground",Color.BLUE);
UIManager.put("current.selectionForeground",Color.GREEN);

Nah that wouldn't.
I will give it one more shot, I will look up source code for one of the L&F projects I know and see if I find something there

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@ceyesuma bellow quoted section is just rubbish. Possibly ex-IT student with little software development background. However if you check his posting history you may find some other lame posts like this

There are several problems to come such errors. sometime java software is not propositional with system. mostly 80% problems faced form this. you have to reinstalled latest software of java. if you not set the right path of java then also error is occured. and sometimes your class declaration is wrong which is silly mistake. so do analysis on this.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

No worries James I'm not complaining. Just saying that may answer was done the way not give out all, try to push OP to think about and either solve it or take further action on it. I do not see anything wrong with you giving him hint after the specific question was posted.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

That what meant without making it obvious ;)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There are several problems to come such errors. sometime java software is not propositional with system. mostly 80% problems faced form this. you have to reinstalled latest software of java. if you not set the right path of java then also error is occured. and sometimes your class declaration is wrong which is silly mistake. so do analysis on this.

Do not reply to technical articles if yo have no clue. Your signature spamming is not welcome, you do it again and we will take action.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There are plenty of example/tutorials on the internet, just use Google ;), just like this one

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I would have put all characters (upper and lower cases) that I would like to use in the same collection, unlike you put it in four different. Take it size and run random generator on collection size number of times declared by me or user.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

The default answer would be : the same way as you did it for one image. Retrieve collection of image objects from database and use loop to get it in grid layout. If you posted code somebody could already helped you

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You are getting logic of Java web development in wrong way. JSP is just presentation layer that is supposed to collect and present data. It is servlet and classes associated with it that are "hard workers" and handle logic.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

1. Do not use JSP for communication with form. Pass data from JSP page to servlet and this should open connection to database and save data. You can find example here
2. Instead of using plain Statement have look on PreparedStatement (also used in previously linked tutorial)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Why you are trying to inject second page that is obsolete there? If you want to be sure user entered values and these are of correct format use JavaScript/Ajax/jQuery to do on form validation and submit form only if conditions are fulfilled.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

That is a simulator for checking what ever you built, not for building. To build you need to use IDE (IntelliJ IDEA, Eclipse, NetBeans) or Dreamweawer or any editor. You can find tutorials on w3schools for example

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There was Openwave simulator few years back, but Openwave sold this product and I didn't see it. You can get download from here or from this blog

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

With only class file little chance of success since it is standard Java, where most phones either support Java Microedition ( a lot cut down Java SE) or run different Java (like Android with Dalvik JVM)
Your best chance is to rewrite it.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

never try it before, but apparently changing properties of UIManager before creating progress bar should work. Something like this

UIManager.put("ProgressBar.selectionBackground",Color.BLUE);
UIManager.put("ProgressBar.selectionForeground",Color.WHITE);
JProgressBar progressBar.....
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If you search JSP section you would find few older posts asking/suggesting some Java web hosting companies. I heard of some free hosting, but this is always heavily overloaded with advertising and you do not have access to server (you have to always ask for restart and other stuff). So either get shared server or private.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If this wouldn't be mobile section and we been in Java I would say use BufferedReader.
Since this is mobile section
iPhone - idea
JME - no reading line by line, you need to implement your own parser
Android - BufferedReader

PS: In the future would be nice if you stated which platform we looking at...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

As I said previously you need to check string length as ~s.o.s~ advised in first place

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    String name = request.getParameter("name");
    String address = request.getParameter("address");
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    if (name.length() == 0) {
      out.println("The name field cannot be left blank <br>");
    } else if (address.length() == 0) {
      out.println("The Address field cannot be left blank <br>");
    } else if (username.length() == 0) {
      out.println("The Username field cannot be left blank <br>");
    } else if (password.length() == 0) {
      out.println("The Password field cannot be left blank <br>");
    } else {
      out.println("Succesfully logged in");
    }
  }
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

No problem, I'm just trying to keep it clean here ;)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Please re-post code in code tags so we can read it.

James please do not ask people to repost their code again, rather advise on using code tags for future posting. As you know multi-posting is against forum rules

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

am not getting you provide me with the code please

Your reply doesn't make sense...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I use netbeans 6.9 and it works fine.

Try to check if ther is a duplicate file "java.exe" in the directory Windows or Windows32 then remove it: after that it should work.

Best regards

Luca

That would depend on the Android version which you set up in NB. I'm not aware if NB getting any upgrade in regards of this plugin...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Yes for upload you need form.
As for which is better JExcel or POI, I cannot say as I used only POI which was very easy and painless.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Classic example of clashing multiple drivers locations.

Never mess around with Java installation directory!

Meaning delete that driver out of C:\ ... \Java\jre6\lib\ext and keep it either in server common library, Tomcat 5 and lower versions TOMCAT_DIRECTORY/common/lib, Tomcat 6 TOMCAT_DIRECTORY/lib or have it in project library folder TOMCAT_DIRECTORY/webapps/YOUR_PROJECT/WEB-INF/lib.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You need JSP to get file from user and forward it to user. To download it you should use Commons FileUpload or similar. Once you have file in servlet you want to use Apache POI to manipulate Excel

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Your validation if statements should not use NULL but for example address.length() == 0

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@mith_cool did you actually read and understand what ~s.o.s~ told you above??? Check for string length

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Thread closed, please refer to the second instance that was left open here

@churva_churva I recommend you start following forum rules or you will soon face closed doors of this forum.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

So what does your method needs to do?
1. Receive char array
2. Maybe you want to run check if each element of array is in deed number. Since you have already array of characters you can use loop to get each of them and check if is number with Character method isDigit(char ch)
3. If all elements are numbers continue to conversion. There is no direct conversion char array to integer therefore you need other way. What can be build or created out of char array? You can use Character method toString() with loop and appending character at the end of a string. Too manual, what about StringBuilder and method append(char[] str)? Still needs a call to convert to string, hmmm. Why not try String class directly? One of many String class constructors is String(char[] value), great use it
4. Now we have String object. Is there way to make it integer? Of course we do! You already implemented in MyInteger class!

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

To be fair I know only of XML libraries provided for JME and no Excell (Office) one. I know there are some midlets available but these are commercial products. Try to look into BlackBerry libraries if there is any chance to get their library on common mobile device. Do not invest much time in it, JME is dying by slow painful death

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Liana that is highly unlikely. You have following options
1. Host it at home and open, made it accessible through IP and port
2. Ask your school if they have database hosting available to students
3. Get (buy) your self hosting on some server

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

But I don't fully understand how to implement the following. For instance, the User_A & User_B have installed my application on their computers. The user_A has rights to only read the data, whereas the USER_B is allowed to read and write the data. So, how could I check which action right the user has?

Ever heard of user groups??? User/Moderator/Administrator/Owner...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

To be fair I never messed up with JAD and took it for granted that is correct. To my understanding JAD function is in detection of device capabilities. Because JAD is just few kb in size it should be used by internet sites to send this file in first place to find out if device is capable run midlet and only after that JAR should be forwarded, as JAR can be large in tenths of Mb

If you want to have look and tweak your JAD here is official guide to parameters

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If everything is fine then please mark thread as solved. Thank you!

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Well what I was trying to say is that you cannot send byte array as sort of object that you can simply pick up from request through parameter request. You have to choose either work with parameters or have stream that is then transferred to a document(image, pdf or similar document upload). However you can run your freshly encoded data stored in byte array through simple method to turn byte array to hexadecimal string

if (pwd!=null){
        	os=writeStr("&password=", os);
            os=writeBytes(new String(HexCodec.bytesToHex(pwd)).getBytes(), os);
        }

with use of following simple class

public class HexCodec {
  private static final char[] kDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    'a', 'b', 'c', 'd', 'e', 'f'};

  public static char[] bytesToHex(byte[] raw) {
    int length = raw.length;
    char[] hex = new char[length * 2];
    for (int i = 0; i < length; i++) {
      int value = (raw[i] + 256) % 256;
      int highIndex = value >> 4;
      int lowIndex = value & 0x0f;
      hex[i * 2 + 0] = kDigits[highIndex];
      hex[i * 2 + 1] = kDigits[lowIndex];
    }
    return hex;
  }

  public static byte[] hexToBytes(char[] hex) {
    int length = hex.length / 2;
    byte[] raw = new byte[length];
    for (int i = 0; i < length; i++) {
      int high = Character.digit(hex[i * 2], 16);
      int low = Character.digit(hex[i * 2 + 1], 16);
      int value = (high << 4) | low;
      if (value > 127) value -= 256;
      raw[i] = (byte) value;
    }
    return raw;
  }
}

Then on the other …

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry dude this is development forum not user trouble shooting of how to use mobile device or why you choose bad price plan...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I see what you trying to do now! I are looking for secure way to forward credentials (username, password). For this you should use BouncyCastle library to encode it on client side and then send it to server side for decoding and further processing

I have sample somewhere of it if you want and can find it for you if you want it...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I was playing around with your code and so far did not found out why send string on server side once retrieved from request is coming out as null...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This should be moved to IT Professionals' Lounge for time being as this is best place at the moment.

PS: I would like to see this in Databases section, but not possible. If you would like to see it also there add your opinion here

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

PROJECT_DIRECTORY

  • *.html, *.jsp
  • images
  • css
  • WEB-INF
    • web.xml
    • classes
      • *.java
      • packages
    • lib (any additional libraries you may need JDBC, JSTL, JSF, Hibernate, etc)
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@raghujosh sorry for late reply. To solve 404 that you had originally you need to included mapping for your servlet. Just add mapping as showed bellow and you are sorted. You will need to go back to your original folder layout

<servlet>
  	<servlet-name>UpdateDBServlet</servlet-name>
  	<servlet-class>UpdateDBServlet</servlet-class>
  </servlet>
<servlet-mapping>
        <servlet-name>UpdateDBServlet</servlet-name>
        <url-pattern>/UpdateDBServlet</url-pattern>
    </servlet-mapping>

As for the second one, well I believe you compiled your Java file directly from the folder where is saved. Because your class has now package it will create new folder for you named by package and your class will be stored there and hence server cannot find it (not even manual copy&paste would help). Make sure that when you compile you are outside of you classes directory such as

javac -classpath /PATH_TO_TOMCAT/lib/servlet-api.jar:classes:. /classes/UpdateDBServlet.java

Incase of Windows OS replace servlet-api.jar:classes:. with servlet-api.jar;classes:.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

1. Your HTML is wrong. Form tags should encapsulate fields you want to retrieve
2. If you post also Java class and web.xml file I may try to run it and see where is problem

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Your server cannot find your Java class that should be inside PROEJCT_FOLDER/WEB-INF/classes. For more details on project folder structure check Tomcat documentation here

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Ahhh sorry this one is wrong. Above example is for text field not combo box.(bad idea trying to reply at midnight when sleepy)
I will look into it again once I get home, sorry again

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

All you need to is monitor mouse clicks in/over the component and mark starting caret and ending caret. Magic done

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class JTextFieldDemo {

  JLabel jlabAll;
  JLabel jlabSelected;

  JTextField jtf;

  JButton jbtnCut;
  JButton jbtnPaste;

  public JTextFieldDemo(){
    JFrame jfrm = new JFrame("Use JTextField");

    jfrm.getContentPane().setLayout(new FlowLayout());
    jfrm.setSize(200, 150);
    jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jlabAll = new JLabel("All text: ");
    jlabSelected = new JLabel("Selected text: ");

    jtf = new JTextField("This is a test.", 15);
    jtf.addActionListener(new ActionListener(){
       public void actionPerformed(ActionEvent le){
         jlabAll.setText("All text: " + jtf.getText());
         jlabSelected.setText("Selected text: "+ jtf.getSelectedText());
       }
    });

    jbtnCut = new JButton("Cut");
    jbtnPaste = new JButton("Paste");

    jbtnCut.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent le){
        jtf.cut();
        jlabAll.setText("All text: "+ jtf.getText());
        jlabSelected.setText("Selected text: "+ jtf.getSelectedText());
      }
    });

    jbtnPaste.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent le){
        jtf.paste();
      }
    });

    jtf.addCaretListener(new CaretListener(){
      public void caretUpdate(CaretEvent ce){
        jlabAll.setText("All text: " + jtf.getText());
        jlabSelected.setText("Selected text: "+ jtf.getSelectedText());
      }
    });

    jfrm.getContentPane().add(jtf);
    jfrm.getContentPane().add(jbtnCut);
    jfrm.getContentPane().add(jbtnPaste);
    jfrm.getContentPane().add(jlabAll);
    jfrm.getContentPane().add(jlabSelected);

    jtf.setCaretPosition(5);
    jtf.moveCaretPosition(7);

    jfrm.setVisible(true);
  }

  public static void main(String[] args){
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        new JTextFieldDemo();
      }
    });
  }
}

Code as can be found in Swing - A Beginner's Guide by Herbert Schildt pg.262-264

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You better use Eclipse as NB Android plugin

  • never worked properly,
  • they been behind version deployment bellow is quote from official documentation
    • platforms/android-1.1 - a target matching to older SDK1.1 platform
    • platforms/android-1.5 - SKD1.5
    • add-ons/google_apis-3 - SDK1.5 + Google Maps API
  • lastly this plugin was developed as part of Kenai project that was few months back axed by Oracle so dunno how much support and progress is there...
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Well I try to read, when I have time, Professional Android 2 Application Development. It is not exactly my style but it was best structured from what I need it. Try to have look Beginning Android 2 and see if that suite your style of learning (google book preview that is listed is very handy)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster