1,963 Posted Topics
Re: You can have the action of the form be the same page. Like: [ICODE]<form action="" method="get">[/ICODE] The submit tag should be like this: [ICODE]<input type="submit" value="Send" name="submitTag" >[/ICODE] Then at the same page; you can write that code wherever you want: [CODE] String name = request.getParameter("name"); .... String submit = … | |
Re: Try to print the stack trace in order to get a better understanding: [CODE] <% try{ java.net.URL url =config.getServletContext().getResource("/textfile.txt");BufferedReader buffreader =new BufferedReader(new InputStreamReader(url.openStream())); String strLine; while ((strLine = buffreader.readLine()) != null) { out.println(strLine); } }catch (Exception e){ e.printStackTrace(); // HERE System.err.println("Error: " + e.getMessage()); } %> [/CODE] You probably get … | |
Re: There is no such function. Can you post the code? | |
Re: First of all: Delete the entire code. Never do that again. That code needs to be in a separate class. Create such a class and put the code that connects to the database and does whatever you want in a method and call that method. That method should return(true/false) whether … | |
Re: The NullPointerException could mean that something is null at that line. Can you try this small debug code: [CODE] <%@page import="bank.User"%> <%@page import="java.util.List"%> <%@page import="bank.BankHelper"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>Hello World!</h1> <% BankHelper … | |
Re: When you login, put the user name into the session: [ICODE] session.setAttribute("USERNAME", <username_of_the_user>); [/ICODE] When you log out remove it: [ICODE] session.setAttribute("USERNAME", null); [/ICODE] And in every page take the USERNAME from the session and check if it's null. If it is then who ever went to that page hasn't … | |
Re: Take the name as a String and then manipulate it. Shouldn't be that hard since you are already moved on to jsps. | |
Re: Post the line where you get the exception. If you read the stack trace you will find it. Also it is clear from the message what the problem is: [B]java.lang.ArrayIndexOutOfBoundsException: 1 >= 0[/B] You are trying to access an array (or some thing like that) with invalid index. Also this … | |
Re: Each if checks a different number. You should be checking only one variable which should be renamed to choice for easier reading and understanding the code. Just because you can name a variable: [ICODE]int shdnjbscsfdcmc = 1;[/ICODE] It doesn't mean you should because no one understands what it does. Read … | |
Re: Did you enter an integer number? Usually when I got that exception with scanner it was because of that. Because I see this at what you posted: [B]Enter Employee Contact Number:456645[/B] Are you sure that is where you get the error. The exception tells you where you got that error: … | |
Re: Example: [CODE] class Contact { private String name = null; public Contact() { } public Contact(String name) { setName(name); } public void setName(String name) { this.name = name; } public String getName() { return name; } } [/CODE] The name is private so no one can access it outside the … | |
Re: What errors do you get and how does the code behave? What does it do that it is not suppose to? | |
Re: The aList is java.io.File. When you do: [B]System.out.println(aList)[/B] What the compiler actually does is, it calls the toString method of the object you passed as argument to the println method. So: [B]System.out.println(aList.toString())[/B] So my question is. What do you want to save in your file? The file names? : ScanFiles.getFileList() … | |
Re: Loop the ArrayList. Then each element is also an ArrayList. So take each element of the first ArrayList and loop that to in an inner loop: [CODE] ArrayList<ArrayList> [B][COLOR="Red"]list[/COLOR][/B] loop [B][COLOR="Red"]list[/COLOR][/B] { take each array_list inside [B][COLOR="Red"]list[/COLOR][/B] loop that array_list { // do whatever } } [/CODE] But I don't … | |
Re: Doesn't the JList already do what you want? Why do you need the tag? [CODE] MyObject myObject = (MyObject)jList.getSelectedElement(); [/CODE] Have you looked the API for JList, or examples? EDIT. Why don't you put "My Object" as a String attribute in the class MyObject and loop the JList and search … | |
Re: [QUOTE=sindhuravindran;1455731]hi.. i want to develop a GUI for the Grid in my company.. so pls someone provide me with a code for job submission in grid.. job submission module includes submission of a job, status of job, cancelling and retrieving output of a job.. if not a complete code, atleas … | |
Re: The exception must be in its own class - file. So you will have 3 files: MyDateException.java TestMyDate.java MyDate.java In the constructor of MyDate if the isValid method returns false, you will throw the exception. Apart from that you are ok. Although you will need to correct the logic in … | |
Re: [CODE] String []irawan=new String [i]; [/CODE] The 'i' needs to be an integer. You initialize like this: String []irawan=new String [5]; Not like this: String []irawan=new String ["5"]; Also you loop the array like this: for(int k=0;k<[B]p.length[/B];k++) p is the array. Not like this: for(int k=0;k<[B]i.length[/B];k++ ) i is not … | |
Re: Can you post again the code using code tags? Just click the button (CODE) and put your code between the tags. | |
Re: You can use the Locale class to get the current configuration | |
Re: I don't remember the exact syntax for the auto-increment, but you can try this: Instead of having the auto-increment part in the insert query: ex: insert into table (id, ... ) values (NEXT_VAL, ... ) You can have a select that returns that auto-increment value: ex: select NEXT_VAL from dual … | |
Re: Read the error messages:[B] Only a type can be imported. org.apache.commons.fileupload.disk.DiskFileItemFactory resolves to a package[/B] Since DiskFileItemFactory is a package, you [U]know[/U] that it cannot be imported like that. Packages are imported like this: org.apache.commons.fileupload.disk.DiskFileItemFactory[B][COLOR="Green"].*[/COLOR][/B] Example: java.util[B][COLOR="Green"].*[/COLOR][/B] or java.util[B][COLOR="Green"].Date[/COLOR][/B] NOT: java.util | |
Re: First of all phrase is the input file and phrase2 is the word you want to search. why do you compare them. Also never compare Strings with == or != . Use: equals: str1.equals(str2) Try running this code: [CODE] while (fileScan.hasNext()) { String line = fileScan.nextLine(); if (phrase2.equals(line)) { System.out.println("This … | |
Re: Read the error messages, go to the lines they say and try to correct them. Also do some studying. Most of the mistakes are because you failed to "copy" correctly the commands from your book or notes to the editor. Look again how the commands are syntax-ed. You should have … | |
Re: How many [B]columns[/B] does the query return? Try: [CODE] textAr.append(rs.getString(1)+"\n"); textAr.append(rs.getString(2)+"\n"); textAr.append(rs.getString(3)+"\n"); [/CODE] Or [CODE] ResultSet rs = stmt.executeQuery("Select col1, col2 from names"); ..... textAr.append(rs.getString("col1")+"\n"); textAr.append(rs.getString("col2")+"\n"); [/CODE] | |
Re: session.setAttribute("[B]sessumobile[/B]", user1) session.getAttribute("[B]sesspassword[/B]") | |
Re: First of all, the methods for smallest, largest are wrong. You initialize at both cases with zero. For example you set smallest=0, but what if the user enters only positive numbers, at the accept method?: [B]1[/B],2,3,4,5,.... Then the smallest 0 will always be smaller than all the elements of the … | |
Re: You can use the same code you use to get the file from the request in order to get the text. Can you use post some part the code that you use to take the file from the request? There are different libraries for that. | |
Re: [QUOTE=erdhaval;1504912]i have this type of code like User:<select> <option>Faculty</option> <option>Student</option> </select> now what i want when i am selected Faculty option then page will be redirect to Faculty.jsp page is it possible in jsp ...plz reply me ...[/QUOTE] Start a new thread and read about onclick events: [CODE] <select onchange=""> … | |
Re: What do you mean lost focus. All we see here is the same code posted twice. Do you submit at the same page? If yes then what happens is that the page reloads. You need to take the value of the radio button from the request and set the attribute … | |
Re: Delete everything. Don't use the above code. (Html in servlets) Create a class with attributes the id, nme(name ?), twn(town ?), cny(country ?). Create a class that has a method that does the database operations and returns the data. Probably a list of the above class (id, nme, twn, cny) … | |
Re: As [I]masijade[/I] said the error has nothing to do with database. You call a method that throws an exception. Regardless if that method will ever throw that exception at Runtime or not, according to the declaration of that method you must catch the exception that it throws. The above has … | |
Re: Submit to the same page with the results, instead of going to a new page. Always display the search criteria and if there was any input in the request and there were results also display those. Assuming that you submit to a servlet, you take the results and send them … | |
Re: Are you saying that your professor didn't teach you how to create forms (JFrame) ? How to click buttons (ActionListener) Or how to create your own classes? [CODE] class Book { String name; String author; .... } [/CODE] | |
Re: Actually, if I may suggest, the initialization should take place in the constructor. So when the user creates that object, the array would be initialized and not having to call any other methods. We usually initialize things in the constructor. Of course the method init_matrix could be private and be … | |
![]() | Re: First of post what errors you get. Specifically the exception. Don't use: System.out.println(e) , use e.printStackTrace. And show us the line where you get the error. Test that method in a main method first Also this is wrong: if(r == null) ResultSet is never null. Use: if (r.next()) { return … ![]() |
![]() | Re: You said that you wantd help, not someone to do your program from scratch. There are a lot of solutions fro this problem, so don't expect someone just to hand you the complete code. You need to show us how you want to implement it in order to point you … |
Re: [QUOTE=JamesCherrill;1498417]You have two challenges - first to think through the logical process you need, second to translate that into Java code. You can't start the second until you've completed the first. So the best thing you can do is to set the PC aside, grab a pencil and pad of … | |
Re: Apparently he wants to add java scrip-lets. Like this: [CODE] <body> <select> <% for (int i=0;i<12;i++) { %> HTML CODE FOR MONTH OPTIONS. <% } %> </select> </body> [/CODE] Try to run the above and see what it prints. I would advise you to study a little bit more about … | |
Re: Actually I believe that you need to call the setLenient method of the SimpleDateFormat class. Check the API. I think that is something that needs to be added to the code. | |
Re: This assignment looks very familiar with this one: [URL="http://www.daniweb.com/software-development/java/threads/347028"]http://www.daniweb.com/software-development/java/threads/347028[/URL] Someone posted the same exact question. The answer that I gave, can be found there | |
Re: You can do that with javascript. Example, add an onchange event at the select tag. When you change something make the fields editable. Then take the values of those fields and check them if they are filled. You can use javascript to change the content of the select box. For … | |
Re: May be this time you can skip the servlet part and the RequestDispatcher. I don't know if it will work, but instead of submitting to the servet you can submit directly to he page you want, and put scriplets in the page. Assuming you submit directly to a page. Then … | |
Re: First of all, that is not proper way to write jsp. A minor error is that in a jsp you never do this: [ICODE]<% out.println(hav);%>[/ICODE] You do this: [ICODE]<%= hav %>[/ICODE] And for the rest of the code this is how you need to proceed: Create a separate class, called … | |
Hi, I recently decided to learn how to program and distribute applications for iPad. After some research I have some questions. I found similar threads in this forum but none where exactly what I wanted. 1) Do I have to buy a Mac to develop my iPad program? After reviewing … | |
Re: Actually, you never create pages nor write HTML code in servlets. You may be able to do that, but you don't. You use servlets for handing data, doing operation, reading from database and then you send the results to the jsp page. It is not a good idea to write … | |
Re: In the mean time you can you look at the java.lang.String API. There are methods you can use. I think there is one called "endsWith". | |
![]() | Re: Is this line 19: if(first.next == null) { //this line If yes then according to the exception you are trying to use something which is null. In this case I assume that it is the "first" I don't know your logic but, maybe you need this: if(first == null) { … |
The End.