peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You should have either web service, or sort of interface that you call on example mysite.com/products?category=all or mysite.com/events?country=UK&city=London where in URL you submit has all data you need for server side so it then can call on DB and return result in some sort of data format (JSON is most commont becuase is cross platform independent)

newuser17 commented: Thanks for the example +0
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

That is just font not language support. Big difference!

And why did you down voted me? I gave correct answer

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Imported project and link it with JBoss. However I'm not able to find back of database with tables you promissed

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Will look at it tonight

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Of course because you use i.next() twice on same line therefore you move to possitions. So if you have followinf courses in arraylist {"math", "english", "java", "c++", "php"}
when you come acrros <%= i.next() %> it will get math but when you hit value="<%= i.next() %>" it will get english and so on. That on its own wouldn' cause problem beside title of row and actual value of radio wouldn't match, your problem i sthat you have array size that is odd number so when it reads php there is no pair value.
You should store i.next() value into temporary string that you can then use instead of double of i.next(). Other option is to use for each loop

ArrayList<String> cs = CourseAssignments.getInstance().getStudentCoursesByName(sname);
for(String course : cs){%>
    <tr>
        <td><%= course %><input type= "radio" name= "courses" value="<%= course %>"/></td>
    </tr>
<%}%>
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Nope was on bus tour whole day. Today I'm returning back to London so first possibility will be Monday evening.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Did you use NetBeans wizard to setup project or you manually set it up? What server you use? (Tomcat, GlassFish, Jetty,JBoss)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@SagarSe7en you wouldn't believe when I tell that most of us are working so can only reply once off work, therefore can not per posters asap demand (sorry for sarcasm, couldn't resist)

To add on what _avd already provided I need to remind that data should be stored as BLOB object that is supported in many DBs now. See Oracle example

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

As error mention you are missing driver library.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Simple example of post request. You need to check what are the names of the fields for credentials as not everyone stick with username and password

public void postData() {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://www.daniweb.com");

    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("username", "pmark019"));
        nameValuePairs.add(new BasicNameValuePair("password", "My password"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

    } catch (ClientProtocolException e) {
        Log.e("ClassName", e);
    } catch (IOException e) {
        Log.e("ClassName", e);
    }
} 
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

SharedPreferences is what you looking for. Before leaving activity A save data in preferences and then in activity B read it out

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Should be possible with one of these mobile cross-platform frameworks like PHoneGap, rhomobile etc, but be warned that there aren't many free/open source, you will need to buy licence

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Java basics!
Class variable Client a will never get initialized because you cretae another temporary variable in setUp method. Just do a = new Client() same goes for tearDown

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You need to be more specific on what you trying to achieve/having problems with. Obvious staring point Paypal Technical Documentation

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I was able to modify/use this example from Swing - A Beginner's Guide in the past to get it working with text area

import javax.swing.*;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class CaretDemo {
    JLabel labelAll;
    JLabel labelSelected;
    
    JTextField textField;
    
    JButton buttonCut;
    JButton buttonPaste;
    final String allText = "All text: ";
    final String selectedText = "Selected text: ";
    
    public CaretDemo(){
        JFrame frame = new JFrame("Caret Demo");
        frame.getContentPane().setLayout(new FlowLayout());
        frame.setSize(200, 150);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        labelAll = new JLabel(allText);
        labelSelected = new JLabel(selectedText);
        
        textField = new JTextField("This is a test", 15);
        
        textField.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                labelAll.setText((allText + textField.getText()));
                labelSelected.setText(selectedText + textField.getSelectedText());
            }
        });
        
        buttonCut = new JButton("Cut");
        buttonPaste = new JButton("Paste");
        
        buttonCut.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                textField.cut();
                labelAll.setText(allText + textField.getText());
                labelSelected.setText(selectedText + textField.getSelectedText());
            }
        });

        buttonPaste.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                textField.paste();
            }
        });

        textField.addCaretListener(new CaretListener() {
            public void caretUpdate(CaretEvent caretEvent) {
                labelAll.setText(allText + textField.getText());
                labelSelected.setText(selectedText + textField.getSelectedText());
            }
        });

        frame.getContentPane().add(textField);
        frame.getContentPane().add(buttonCut);
        frame.getContentPane().add(buttonPaste);
        frame.getContentPane().add(labelAll);
        frame.getContentPane().add(labelSelected);
        
        textField.setCaretPosition(5);
        textField.moveCaretPosition(7);
        
        frame.setVisible(true);
    }
    
    public  static void main(String[] args){
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new CaretDemo();
            }
        });
    }
}
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Simple, when you call method to interact with database provide parameters with it instead of trying to get direct access.
Example, this is very simplified JAVA!!!
Before change

public boolean login(){
PreparedStatement preparedStatement = null;
	try{
		String strQuery = 
		"SELECT * FROM user WHERE uid=? AND password=? AND";
				
		preparedStatement = conn.prepareStatement(strQuery);
		preparedStatement.setString(1,usernameTextField.getText());
		preparedStatement.setString(2,passwordTextField.getText());

would become

public boolean login(String username, String password){
PreparedStatement preparedStatement = null;
	try{
		String strQuery = 
		"SELECT * FROM user WHERE uid=? AND password=? AND";
				
		preparedStatement = conn.prepareStatement(strQuery);
		preparedStatement.setString(1,username);
		preparedStatement.setString(2,password);

and you will call it from your user interface presumable on button click as

public void actionPerformed(){
    DataManager manager = new DataManager(); //Your database class
    manager.login(usernameTextField.getText(), passwordTextField.getText());
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Edit: wait, zeroliken, you're in Japan? I know nothing about the Japan job market and how Japanese employers behave. Maybe what I say doesn't apply to them, and having OCJP or whatever certifications is this magic requirement. I'm talking about the American or you might say American/UK job market (based mostly on developers I know who work in the UK), especially with a bias towards west coast tech companies and similar companies that know what they're doing.

I do agree with this, however we should not forget that in many Asian countries (Bangladesh, India, Pakistan) there is high pressure from employers to accept only certified people. This is unlike in Europe or America where previous work record and open source contributions are more valued. However by meeting some people from Japan finance industry I would say it would not hurt your CV, but you will definitely have better chances if you are participating in some project.

@Mushy-pea contribution to some projects, attending some IT user group (meetup.com is good place to search for one in your area, example GDC, LJC - London Java Community), voluntary work or intership are the best starting block for new candidates in UK

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Thread close due to multi posting. Please follow further discussion here

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I guess you will need to ask him for some references on his claim as I believe he is wrong since following resource, which are for Java says otherwise

"You might expect that a += b; is identical to a = a + b; when the two are compiled, but that is not the case. In fact, these cause different Java bytecodes to be generated, and the second approach actually takes longer to execute. Therefore, you can make minor improvements in the speed of your code by using compound operators such as +=, -=, *=, and /=." Professional Java Programming.

Strength reduction pg 154-155, Practical Java - Programming Language Guide

zeroliken commented: nice +9
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Have look on Java Advanced Imaging project

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@.kaine and @dantinkakkar stop down-voting each other posts or I will take out my "moderator stick" and start beating each of you.

@.kaine if the answer is not what you expected that means that you did not explain your problem properly

@dantinkakkar if someone is refusing your help you better decide if you want to continue discussion

End of story!

dantinkakkar commented: Yo! =D Sorry, peter +0
jbennet commented: some sense finally +0
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Yes exactly StringBuilder is better way then what you showed in VB which is also possible in Java/Android

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

The answer is yes and no. No in case that PDF is actually batch of images that been previously scanned and just converted from what ever image format to PDF(they would need to under go OCR- optical character recognition process which is not 100% perfect)
Yes you can, and should be able to do with iText PdfReader and get page build components, or you can use Apache PDFBox which should be more flexible in the way of data extraction from PDF.

@NormR1 POI is for Microsoft Office document formats(Word, Excel, etc)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

As far I know from 2.3.0 or similar version PDF viewer is available on most of devices since they want to be direct competitors for Kindle and other e-book readers

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You just made over kill. There is easier way to work with PDFs then open+conver+display in application. See this simple example

PS: I bet that you are one of these people that rather see movie of the book then reading it, like Lord of the Rings. Movies been great but book is even greater ;)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You know the idea is that JSP page present some data. On button or link click you request something from server that is handled by servlet. Servlet handle this and then forward data JSP page.
So if you tell us little more about what you trying to do we can help. To get basic idea of JSP-servlet interaction you can always look at MVC tutorial at top of this section and there is also FAQ section that list various learning resources if you interesd

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@rushikesh jadha

1) Both post merged - forum rule Keep It Organized Do not post the same question multiple times
2) Next time you create thread you better give it a proper name not "java help". We are in Java section and people posting here do need help - forum rule Keep It Clear Do use clear and relevant titles for new threads
3) You are expected to show effort and not just beg for answers. Just simple search on Google would gave you ton of resources "Java MySQL tutorial" - forum rule Keep It Organized Do provide evidence of having done some work yourself if posting questions from school or work assignments

Next time you fail to do any of above I will merciless delete your thread!

stultuske commented: sometimes a wake up call is the right thing to do +14
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

bump
>>You are rude! This is not 24/7 give my codes forum, but voluntary work of people that are willing to help when they have time.

1) First thing first, slap your self for doing database connection from JSP and not from servlet
2) You are handling your connections in bad way. Do NOT create new connection in existing connection and then to try to close it as part of same try block

Therefore move database code to servlet.
Split code in number of methods that you will call once certain conditions rises. Start first with methods to get connection and close connection and then create these 3 methods that will handle different queries. Once you done with that we can talk further

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

~!~ For website development which is best asp.net , php , j2ee ~!~

PHP is better than asp.net & j2ee

waLkiNg-aLoNe

And you know it because you failed miserably to learn Java and .NET. If you have something to say you better give full explanation and not biased opinion.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Since you say you know C# (which has very similar syntax to Java) you will do fine. Just need to be more proactive with Android API, little different from MSDN

rotemorb commented: The guy was very helpful :) +1
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I would say go with Beginning Android 4 as Beginning Android 4 for games is for these that have some knowledge of Android already. I'm at the moment reading Android Pro 3, but it is little bumpy ride as authors seems to give to much theory and code is coming in small doses. You can always get code from book on APress site

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Passing out object from form is not good idea. You should not allowed objects that are not associated directly interfere. Better (not perfect solution) would be this

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


public class MyEventC extends JFrame implements ActionListener {

    private JTextField text;

    public MyEventC() {
        setLayout(new BorderLayout(5, 10));

        JPanel topSide = new JPanel();
        topSide.setLayout(new FlowLayout(FlowLayout.LEFT, 25, 3));
        JLabel one = new JLabel("Current value");
        text = new JTextField("0", 10);
        topSide.add(one);
        topSide.add(text);
        text.addActionListener(this);

        add(topSide, "North");

        JPanel southSide = new JPanel();
        southSide.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 3));
        JButton btn1 = new JButton("+");
        JButton btn2 = new JButton("-");
        JButton resetButton = new JButton("Reset");
        JButton btn4 = new JButton("Quit");

        southSide.add(btn1);
        southSide.add(btn2);
        southSide.add(resetButton);
        southSide.add(btn4);
        add(southSide, BorderLayout.SOUTH);

        //text.addActionListener();

        btn1.addActionListener(this);
        btn2.addActionListener(this);
        resetButton.addActionListener(new ResetListener(this));
        btn4.addActionListener(this);


    }

    public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand() == "+") {
            int num1 = Integer.parseInt(text.getText());
            num1++;
            String result = num1 + "";
            text.setText(result);
            System.out.println(num1 + "");
        } else if (e.getActionCommand() == "-") {
            int num1 = Integer.parseInt(text.getText());
            num1--;
            String result = num1 + "";
            text.setText(result);
            System.out.println(num1 + "");
        }


        else if (e.getActionCommand() == "Quit") {

            System.exit(0);
        }
    }

    public static void main(String[] args) {
        MyEventC event = new MyEventC();

        event.setTitle("Part 4 Using separte class for Reset Button");
        event.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        event.setSize(400, 150);
        event.setVisible(true);

    }

    public void resetForm() {
        text.setText("0");
    }
}
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ResetListener implements ActionListener {
    private MyEventC myEventC;
    public ResetListener(MyEventC myEventC) {
        this.myEventC = myEventC;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if ("Reset".equals(e.getActionCommand())) {
            myEventC.resetForm();
        }

    }
}

PS: It is about time that you start giving …

DavidKroukamp commented: That is neater +7
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

1) In same time as you add these data to Excel you can call a method to save it also in database (You know you have these data in some sort of object which is once used to store it in excel, but you can reuse it and forward to database)

2) What sort you looking for, just by name, type, date some specific info? Is this all gone be run on Android device or is it also desktop application?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You could have moved that system messages also into methods with which they are associated and code would be little more readable :)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Something like this?

public class ComponentTest{

    public static void main(String[] args){
        Component[] components = new Component[]{new Component("motherboard", 1234567),
                new Component("processor", 2345678), new Component("hard disk", 987654)};
        
        for(Component c : components){
            c.print();
        }

    }
    
    private static class Component{
        private String name;
        private long serialNumber;
        
        public Component(String name, long serialNumber){
            this.name = name;
            this.serialNumber = serialNumber;
        }
        
        public void print(){
            System.out.println(name + " - " + serialNumber);
        }
    }
}
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@history better mind your manners and start cracking on that code as we have here one rule for lay people

Do provide evidence of having done some work yourself if posting questions from school or work assignments

Otherwise nobody will help. We are NOT 24/7 coding forum for lazy people

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Giving the poor coding I may have overlooked that... Nevertheless there was no point for down-vote from you given that even my approach is valid solution.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Eclipse official documentation Creating a New JAR File

DavidKroukamp commented: beat me to it ;) +4
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If you want to just create click on browser you may want to look into Selenium library (nice library used for testing web applications)

mKorbel commented: thanks for link +1 +11
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

At the time it was privilege to get project hosting, you had to get through tough process of explaining why your project should be hosted etc.
Now days anyone can get project hosted at sourceforge. However in order to survive they have to relay on heavy advertising to support their old software and hardware setup. Due these "problems" number of good projects moved to more flexible and open project hosting solutions. This is how I see it

mikulucky commented: That is a shame :( +0
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry for delay.
My MVC tutorial was written long time ago before I become friend with IntelliJ so I did direct development in Tomcat webapps where I created project folder there.

Trying to solve your issue through IDE and folder structure you have, I had to change web.xml servlet-class definition to

<servlet-class>Servlet.LoginServlet</servlet-class>

and removed anotation from LoginServlet

@WebServlet("/Controller/Login")

after that I was able to read data from config. Let me know if you still have some problems. (If I get more time I may try to create this tutorial with Hibernate)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@Ms New to Java
1)Multiposting not welcome!
2) Use code tags when posting any code such as [code] YOUR CODE HERE [/code]
3) Thread closed. For further discussion follow this thread

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I had look on Java Plot that I think will use with one of my pet projects

mKorbel commented: happy new year, thanks for link +10
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Its paid library(as from what I seen on multiple links I had to go through to find some meaningful info), so you need to contact company for price list

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Forum rules clear state Do provide evidence of having done some work yourself if posting questions from schoolwork assignments. If you not willing to actively participate in the process then it is not our fault that you get "F". We are not 24/7 coding service for lazy people

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

OK, looking at POI code XWPFTableCell consists of number of XWPFParagraphs of which you need to take care. So you need to remove all paragraphs in order to have text replace. You can do something like this

if ((cellNum + 1) == 2) {

      if (tableCellVal != null) {
        if (tableCellVal.length() > 0) {
          removeParagraphs(tableCell);
          tableCell.setText("CHANGE");
        } else {
          //tableCell.setText("NULL");
        }
      }
    }

where removeParagraphs can look like this

private static void removeParagraphs(XWPFTableCell tableCell) {
    int count = tableCell.getParagraphs().size();
    for(int i = 0; i < count; i++){
      tableCell.removeParagraph(i);
    }
  }
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Well this is your project, so why don't you show what you learn so far and do some creative thinking...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I have another query.

When i started learning Servlets and JSP, i come to know that whenever we make any changes in our website project files, then we need to restart our server to implement those changes.

Now suppose when my website is accessed by thousands of people each second/minute, at that time if I try to restart server then my website will become inaccessible for some minutes, isn't it a drawback and unhappy users??

Secondly to jwenting comment, it is usual practice that you will have development server and production. Dev is for continuous development bug fixing and production gets major or regular updates where you can notify users about any downtime.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You can do it with Selenium

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Doesn't seems to be possible with select & options. One of the way I seen suggested was with div and JavaScript

javaAddict commented: Thanks for the reply +13