1,963 Posted Topics
![]() | Re: You cannot combine java and javascript that way. They are NOT the same: [CODE] document.getElementbyName('myCombo').selectedValue = '<%= session.getAttribute("choice") %>'; [/CODE] I see from your previous thread that you lack of lot basic knowledge about jsp and submitting requests. I would suggest to take sometime to learn the basics, study a … |
Re: [QUOTE=gabz16;1290452]yes..or maybe someone who knows the codes for this program[/QUOTE] No one is going to give you the code unless you show some code of your own; more specifically, what have you done so far? | |
Re: Have a counter in each of those methods. When you print something increase it by one. When it reaches 5 or 9, call the [ICODE]System.out.println();[/ICODE] and set it to 0. [CODE] int count = 0; for (loop) { System.out.print("something "); count++; if (count==5) { count=0; System.out.println(); } } [/CODE] | |
Re: Does the Student table actually exists? Have you trying running the query to an sql client? Do you need to set the username, password. Is the host correct? What driver are you using? Have you set that driver to the classpath? Try to find examples on how to connect to … | |
Re: Don't use GOTO in jsps. Start a new thread where you explain what you are trying to achieve | |
Re: [icode]if (cp.bi == null)[/icode] What if cp is null ? Try to print everything before you run anything: [code] File saveFile = new File("SemiTransparentSquare.gif"); System.out.println("saveFile: "+saveFile); if (saveFile == null) System.out.println ("saveFile is null"); System.out.println("cp: "+cp); System.out.println("cp.bi: "+cp.bi); if (cp.bi == null) System.out.println ("cp.bi is null"); ImageIO.write(cp.bi, "gif", saveFile); [/code] | |
Re: That is not a good example and it is a bad way to do things. Not to mention that the OP said nothing about html code. Only the database connectivity is almost ok. You forgot to close the ResultSet, Statement and ResultSet. First: How do you know that the table … | |
Re: You also need to post the exception that you get. Did you put in the classpath the my-sql-connector.jar ? | |
Re: [QUOTE=cwpent;1223018]anyone?[/QUOTE] Where you the one who wrote the Farm class? I need to know this because, I need to understand what was given to you initially. Also you could do this: [CODE] myFarm.add(new NamedCow("Elsie")); [/CODE] ![]() | |
Re: As the error message says, you have a syntax error at your query. You must first write your queries in an sql editor, run it with some values and then take it and put it into your code. In your case it seems that you forgot a comma: "UPDATE empDetail … | |
Re: You can filter the results at your query by adding a WHERE. Look for some tutorials on how to write sql statements with WHERE: select * from emp_details WHERE fname='[I]something[/I]' Then at the jsp page that submits to the ifsServlet you can pass the name or whatever you want as … | |
Re: [QUOTE=rinoel;1063885]According to the output you wanted, I made something very simple, I don't know if that's what you wanted... [CODE]import java.util.Scanner; public class quiz { public static void main(String []arg) { Scanner input = new Scanner(System.in); int x, y, z; System.out.print("Enter your name: "); String name = input.next(); System.out.print("How many … | |
Re: For reading lines from a file: [CODE] BufferedReader br=null; try { br = new BufferedReader( new FileReader( fileName ) ); String line = br.readLine(); while (line!=null) { //do something with line //you read each line of the file, You don't know how many lines the file will have //the last … | |
Re: There is the : document.getElementsByTagName(tagname) from: [url]http://www.w3schools.com/jsref/met_doc_getelementsbytagname.asp[/url] I don't know that mehod, but probably returns all the elements of a specific tag type: document.getElementsByTagName("select") You can loop those and check for each one of those their selectedIndex. For the API of the select element refer to the link I provided … | |
Re: Try to add some System.out.println in the readFile method and see what happens. Also you need to declare the list as a private member of the class like filePath. With your way, you create it in the method readFile and then after it executes, you have lost it, you cannot … | |
Re: Create a method in a class that executes the select query and retrieves the data. Save those data in an ArrayList. In your jsp call that method and with a combination of html and java (scriplet) populate the drop down box JSP: [CODE] <% ArrayList list = yourClass.getData(); int size … | |
Re: [QUOTE=poojavb;1757567]Check if the connection is created to the database [CODE] Connection con; Statement stmt=con.createStatement(); ResultSet rs=null; String ss=("SELECT VIDEOID, VIDEONAME, DIRECTOR FROM VIDEOS"); rs=stmt.executeQuery(ss); while(rs.next()) { //code goes here } [/CODE][/QUOTE] That is not what [I]TIM_M_91[/I] has asked. @TIM_M_91: It is odd that you haven't found the correct syntax because … | |
Re: Then why don't you look at this link: [URL="http://www.daniweb.com/forums/thread141776.html"]JSP database connectivity according to Model View Controller (MVC) Model 2[/URL] It is at the top of the Jsp forum. | |
Re: [QUOTE=nore;1754302]i've got the answer, i hope it would be useful :) Set the varaible into the session in Page1.jsp and access the same in Page2.jsp. In Page1.jsp session.setAttribute("X", "value"); In Page2.jsp String x = session.getAttribute("X");[/QUOTE] Unfortunately that is the [U]wrong[/U] way to pass the value. You should never use session … | |
Re: You can load the servlet directly. Instead of writing at the url: [url]http://localhost:port/index.jsp[/url] you can write: [url]http://localhost:port/YourServlet[/url] | |
Re: [QUOTE=rushikesh jadha;1752767]you can catch array index out of bound exception.[/QUOTE] Never use try-catch for ArrayIndexOutOfBoundsException. You already know at runtime the size or length of what you are trying to use. So always check that. long89: So when looping, it is good to do this instead of what you have: … | |
Re: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at TheatreRevenue$CalcButtonListener.actionPerformed(TheatreRevenue.java:99) At that line and file: TheatreRevenue.java:99 you are using something which is null. Go to tha line and see what is null and make sure it is initialized. Also the code tags you are using should end with | |
Re: [QUOTE=grendel0;1750016]I split the connections and discovered I hadn't even declared stm2 as a prepared statement, rather a redular statement! This fixed the error, I have to agree with you about the amount of code on my JSPs, I'll look at changing the logic to servlets, though my lecturer insisted on … | |
Hello everybody, My question is simple. I wish to develop a web site and I have been looking for web hosts and most offer MySql. At my job we use oracle, but after some searching I haven't found any great differences between them and any real reasons why I should … | |
Re: You don't have to put all those ifs in the index jsp because what you are trying to do should be divided into 2 jsps. Assuming that your first jsp is called: login.jsp. There you don't have to check if the user is logged in. All you have to do … | |
Re: What is the service pack of your windows and can you post the link you used for downloading? | |
Re: To [I]sumitlole[/I]. NO, it is not the easiest way, it is the wrong way. This thread is 2.5 years old. What do you think you can accomplish. In your code you have this: [CODE] System.out.println("Wrong Number Enter again"); if(s.charAt(0)==s.charAt(4) && s.charAt(1)==s.charAt(3)) [/CODE] You print the message "try again" but then … | |
Re: It is not a function and on its own it means nothing. The only thing similar to this, is when I set the data option when making an ajax call with jQuery. [URL="http://malsup.com/jquery/form/"]http://malsup.com/jquery/form/[/URL] | |
Re: The inputs with type="file" work differently. You may be able to take the request.getParameter("importExtruderFile") but you cannot use that path to create a file and read it. I don't remember it exactly but if you search the net you will find what methods to use. Take a look at this … | |
Re: It depends on where you put your image and how you deployed your web application and what server do you use. If you simply used NetBeans to create the .war file or just run your application then the image is not beeing read from where you think it is. In … | |
Re: I am sorry to tell you this, but if you are a beginer with java why do you write jsps? The code that you wrote has several errors, but not because of your lack of effort. Because there some things that you have confused and you need some studying to … | |
Re: Have you tried installing eclipse? Java is not an application. What I did was download java, install it, and installed an IDE (eclipse in your case) of my choice. When I run the IDE it asked me to enter the location of the java that I installed. | |
Re: Is the url correct: jdbc:mysql://localhost/test ? Maybe you are missing the port: jdbc:mysql://localhost:<port>/test As the exception says: Cannot connect to MySQL server on [B]localhost:3306[/B]. Is there a MySQL server running on the machine/port you are trying to connect to? Try to read first the exceptions that you get. They provide … | |
Re: First of all remove all of the database code and put it in seperate methods and classes and call those methods from the jsp. Then read the exception that you get. It tells you exactly what the error is at line 66 The NumberFormatException is thrown when you cannot convert … | |
Re: You don't only get a NullPointerException. You also get a stack trace. Have you tried reading it? It tells you where the error is and what is the problem. You can try posting it, since it is unlikely someone will read AND compile your entire code in order to find … | |
Re: First of all check your query. Always print it before you run it and see what is going on. In this case you have this: [ICODE]"select *from student where no=' " +num+" ' ";[/ICODE] Can you see the blank spaces where you have the quotes. Also you need a space … | |
Re: Can you post some more code? Also you can look at the: [URL="http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JOptionPane.html"]http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JOptionPane.html[/URL] ![]() | |
Re: If you have never done java then why should you get that position? And if you are looking for the entire code we are not going to help you. Besides we don't know if it swing or jsp, or if you want to use javascript to do the validation at … | |
Re: The descriptions are very clear. Just create separate classes for each part. For the account part just create the Account class. In the main call those constructors to create what is asked. You will need a menu for that. If you must have One account per Customer then you may … | |
Hello everybody. I have a question/problem. I have a select tag with several options. Sometimes the text of the option becomes very large. So I tried something like this for example: [CODE] <select> <option>A Very Big <br/> sentence</option> </select> [/CODE] But it didn't work. What I was trying is to … | |
![]() | Re: You will need pure javascript, not java. Have a button. when the button clicks, execute a function that takes the value of the text field. If the values is "username" make it empty: (value="") Check out the tutorials form the [URL="http://w3schools.com/"]W3Schools[/URL] site about javascript ![]() |
Re: You need to post your code and see what happened | |
Re: Use : [URL="http://download.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html"]java.text.SimpleDateFormat[/URL] [CODE] Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("EEEE, MMMM dd, yyyy"); String s = sdf.format(now); System.out.println(s); [/CODE] Try to experiment by changing the number of 'E's and 'M' Check this example: [CODE] Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("EEE, MMM dd, … | |
Re: The encryption takes place in the servlet not when you submit the page. You pass the password the user entered from the gui, so the password at the url is unencrypted. It goes to the servlet where you do the encryption. There is no way to avoid that. (Actually there … | |
This is not much of a question, but a discussion and searching for opinions. I have seen that many use the Scanner class for getting input from the keyboard. Some, like myself, use the BufferedReader. Why will someone use one over the other? Or they both do the same thing … | |
Re: The pop method of the Stack class is not complete. Maybe you have fixed it already, but you need to check if the stack is empty before removing the top element. | |
Re: When you divide an int with an int you get an int: 12/100 = 0 12.0/100.0 = 0.12 [CODE] double percentageH = (1.0*frequencyHeads/totalTosses); double percentageT = (1.0*frequencyTails/totalTosses); [/CODE] You multiply by 1.0 which is a double, so 1.0*frequencyHeads is also now double and 1.0*frequencyHeads/totalTosses is also now double And you … | |
Re: [QUOTE=gap_89;1043565]hey can u help me by dis problem write down an application to display a window with various GUI components available in the awt packages[/QUOTE] You revived an old thread, when the best advice would be to use the javax.swing package. | |
Re: You don't call the actionperformed. It is automatically called whenever you click a button. You implement it normally in the same way you do when you use javax.swing. Your applet should implement the ActionListener interface, then you will declare the actionPerformed method and write code inside it. Then you will … |
The End.