Code That Works On Fiddle But Doesn't Work On Local
Oct 9, 2014
I have this code: [URL] .... It works on fiddle but on local it does not work. What should be the problem?
Fiddle:
$('#addnewline').on('click', function (e) {
e.preventDefault();
var $textarea = $('#thetext');
$textarea.val(function () {
return $(this).val().substring(0, this.selectionstart) + "<br>" + $(this).val().substring(this.selectionstart);
});
});
<button id="addnewline">New line</button>
<br />
<textarea rows="4" cols="50" id="thetext">Some text
View Replies
ADVERTISEMENT
Mar 2, 2014
There is a specific function I have added to a program I've been working with for a while which involves retrieving data from a website. Here is that code:
Java Code: public String getWebData(String urlString, String add) throws IOException{
String output = "";
try {
//+s being the token, for example if dictionary.com was being used
add = add.replace(" ", "+s");
urlString = urlString + add;
URL url = new URL(urlString);
InputStream inputStream = url.openStream();
[code]....
Anyway, when I run this program within Netbeans, it works perfectly. I have a backup of the project in eclipse as well, and I've copied all of the code over and tried running the same thing in Eclipse - exactly the same, it works perfectly. The problem is whether I compile the the code in Netbeans or Eclipse, the exported runnable jar for some reason has an issue with this one method. It doesn't crash, and it seems to be doing something, but it is by no means giving me the data from the website like it is supposed to.
View Replies
View Related
Dec 23, 2014
I having problem on validating email and password whether does it belongs to a registered members or not. I'm using NetBeans and created a database, table name as members. I have done setting up connection pool and fill in data to my members table.This is my members table data.
#|id|email|password|name
1|1|what@what.com|what|Number 1
2|2|fireup@fire.com|fire|Number 2
This is my index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Library Application</title>
[code]....
View Replies
View Related
Feb 18, 2014
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class frmSearch extends JDialog
{
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
JPanel jpnlMain = new JPanel();
[Code] ....
View Replies
View Related
Sep 9, 2014
import com.googlecode.javacpp.Loader;
import com.googlecode.javacv.*;
import com.googlecode.javacv.cpp.*;
import com.googlecode.javacv.cpp.opencv_core.CvMemStorage;
import com.googlecode.javacv.cpp.opencv_core.CvPoint;
import com.googlecode.javacv.cpp.opencv_core.CvScalar;
import com.googlecode.javacv.cpp.opencv_core.CvSeq;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import com.googlecode.javacv.cpp.opencv_highgui.CvCapture;
import com.googlecode.javacv.cpp.opencv_imgproc.CvMoments;
[code]....
Everything works in this except the part where drawing a convexhull and the convexitydefects around an object. Drawing circle around the COG works OK. I tried to draw them with these lines but no luck.
hullSeq = cvConvexHull2(bigContour, hullStorage, CV_COUNTER_CLOCKWISE, 0);
defects = cvConvexityDefects(bigContour, hullSeq, defectsStorage);
cvDrawContours(img1,defects , CvScalar.BLUE, CvScalar.BLUE, 1,0,0);
cvDrawContours(img1,hullSeq , CvScalar.BLUE, CvScalar.BLUE, 1,0,0);
View Replies
View Related
Apr 14, 2015
Why the keyTyped function isn't triggered, when i type a key?
Here is my code:
package main;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
[Code] .....
I have noticed, that if i call setVisible(true) before i add the button, then it works, but the button is not displayed... How can i achieve that the button is displays AND the KeyListener works?
View Replies
View Related
Oct 10, 2014
int arabe = Integer.readLine(args[0]);
String romain= "";
The compilator says that it can't find symbol. The arrow is under the "".""
It worked before.
View Replies
View Related
Jun 10, 2015
I have java http client which sends periodically (every 30 sec; this code is run by heartbeat thread in the cycle) heartbeats:
private PostResponse post(String jSessionCookie, final String action, final String data, final int postTimeoutMs) throws IOException, SSYSException
{
final HttpURLConnection httpConn = openHttpUrlConnection(true, postTimeoutMs, jSessionCookie);
final OutputStream os = httpConn.getOutputStream();
try (final PrintWriter wr = new PrintWriter( DefaultProperty.isEnableSocketTraceGW ? new TracerOutputStream(os) : os ))
[Code] .....
On the server side there is Tomcat 8.0.21 + APR connector. Every time this heartbeat is sent I see in the Wireshark and EtherDetect that new TCP connection is opened (SYN-SYNACK packets) and after getting response from Tomcat connection is closed (FIN – FINACK packets). I was expecting that TCP connections will be reused but not closed.
Capture.png 182.0 K
View Replies
View Related
Feb 24, 2014
Java Code:
import java.io.*;
import java.util.Scanner;
public class asciiFile {
int height;
int width;
Scanner input;
char[][] poop;
public asciiFile(File f) throws FileNotFoundException{ //constructor
[code]...
The constructor is supposed to take an ASCII file, take the numbers in the file, and populate a 2D array with the numbers in the file.
For some reason, the for loop I use to populate the array works outside of the constructor. When I put it in one of the methods, it runs normally. However, when I keep it in the constructor, I get the following error:
Exception in thread "main" java.lang.NullPointerException
at asciiFile.<init>(asciiFile.java:16)
at main.main(main.java:6)
View Replies
View Related
Mar 26, 2014
i am calling a method of my applet from within the javascript. My code works fine with all browsers except CHROME.i get this exception in browser = "Uncaught TypeError: Object #<HTMLObjectElement> has no method 'loadComplete' mainControl.js:6". i called this method on the "onload" of <body> tag.
View Replies
View Related
Oct 30, 2014
Below is my code
<%--
Document : closeAc
--%>
<%@page import="javax.swing.JOptionPane"%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*, java.util.Date;"%>
<%
try {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
[code]....
All I'm trying to do is to search the data from the database and is doesn't show up!
View Replies
View Related
Oct 17, 2014
I'm trying to read a xml file and delete it's contents. I do this by reading the file,writing it to a temp and then overwriting the original with the temp by renaming it
//overwrite original xml file with new file
boolean successful = outputFile.renameTo(inputFile);
System.out.println("success");
It does say the value of the local variable is not used however. I've debugged to ensure it hits the code it always prints out the line after too.It just does not overwrite my original xml file with the temp one.
It's had votes on stack so I thought that would of been reputableStack - overwrite but the second one got voted as a good answer. But still I would like to know if my code can work or not.
View Replies
View Related
Nov 9, 2014
I have a JList<Object> in my code (it actually takes JLabels) called imageList, and I've given it a custom CellRenderer using the following code:
cellRenderer = new DefaultListCellRenderer() {
private static final long serialVersionUID = 1L;
@Override
public Component getListCellRendererComponent(JList<?> list,
Object value, int index, boolean isSelected,
boolean cellHasFocus) {
[Code] .....
However, when I click anywhere on the JList, nothing gets printed to the console, which suggests that the mousePressed() method isn't being invoked. I think it's a problem with the CellRenderer, because I have similar code elsewhere that works, the only difference being I don't use a custom CellRenderer.
View Replies
View Related
Jun 6, 2014
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
if (input == "next") {
System.out.print("good Job!");
}
else {
System.out.println("Why ?");
}
//If I type in next it prints out "Why ?" instead of "Good Job!" - Why though ?
View Replies
View Related
Nov 5, 2014
I am using servlet 2.4 I used the ff. code below to set httponly in my application's cookies but it did not work. When I do a javascrip alert (document. cooke) in my page, the session id still shows up.
Cookie [] cookies = request.getCookies();
for(int x=0; x<cookies.length; x++){
Cookie cookie = (Cookie) cookies[x];
String cookieValue = cookie.getValue();
cookie.setValue(cookieValue + "; HttpOnly");
}
I also tried doing this and it wouldn't work too
String sessionid = request.getSession().getId();
response.setHeader("SET-COOKIE", "JSESSIONID=" + sessionid + "; HttpOnly");
by the way I am using an application server with its JAVA EE version = 1.4 and JAVA SE version = 5
View Replies
View Related
Mar 29, 2014
In fact, I'm not yet past that "Hello World" program.I'm following the steps in "Head First: Java" book, and reached that point where one is ready to write his/her 1st Java code. Here's mine:
public class MyFirstApp
{
public static void main (String[] args)
{
System.out.println("I Rule!");
System.out.println("The World!");
}
}
As simple as it should be, and compiles fine producing the correspondent class. But it doesn't run, however, and spits the following execution-time errors:
Exception in thread "main" java.lang.UnsupportedClassVersionError: MyFirstApp : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
[code]...
View Replies
View Related
Oct 21, 2014
I have two files - I can get the second one to populate with the first ones data and then delete the first one. I cannot get it to then rename itself to the name of the first file. It also only hits the 'rename' section of the code providing I place system.gc in otherwise it completely skips it.
the code I use is below:
Java Code:
finally{
try {
br.close();
// mp br.close();
//mp System.gc();
[code]...
View Replies
View Related
Feb 14, 2015
I am having an issue where the code does something very strange when run. Everything seems to be ok in the code but I don't know what is wrong as no error is given.
Here is the code:
import java.util.Scanner;
public class Pizza {
private static int pizzaSmall = 10;
private static int pizzaMedium = 12;
private static int pizzaLarge = 14;
private static int costPerTopping = 2;
/**@return The total cost of the pizza when given the pizza size and the toppings.*/
[Code] ....
And here is the console output:
Please enter the number of Cheese toppings that you would like: 1
Please enter the number of Pepperoni toppings that you would like: 1
Please enter the number of Ham toppings that you would like: 1
Please enter Small for a Small Pizza, Medium for a Meddium Pizza, and Large for a Large Pizza:
The number of Cheese toppings is 1.
The number of Pepperoni toppings is 1.
The number of Ham toppings is 1.
View Replies
View Related
May 10, 2014
in my ui i will i will select enabled or disabled then it will go in controller , i already debug it and it goes on the right controller based on what i select on ui my problem is when i select disabled it dont display the message but when i select enabled it displays the message, then i check the databases status is change based on what i select but when i change into disabled doesnt display any message.if select enabled will go in controller then change status into true then update the status then will see the message in ui
@RequestMapping(value = "/viewEnabled/{id}", method = RequestMethod.POST)
public ModelAndView viewEnabled(
@PathVariable("id") Integer id) {
ModelAndView mvc = new ModelAndView();
Supplier supplier = supplierService.retrieveSupplier(id);
supplier.setEnabled(true);
supplierService.updateSupplierEnabled(supplier);
mvc.addObject("showEnabled", true);
mvc.addObject("supplier", supplier);
[code]....
The main functionality of enabled /disabled is both working it just dont display the message if i change it into disabled,.
View Replies
View Related
Dec 1, 2014
This was shown in class the other day and I'm still not sure of how exactly it works, even after looking at it through a debugger.
public void sort(){
for (int i = 0; i < size; i++) {
Node temp1 = head;
Node temp2 = head;
Node temp3 = head;
while(temp2.next!=null){
temp3 = temp2.next;
[Code]...
Again, I didn't write this code I'm just trying to understand it. Why specifically do three different temp values need to be used instead of just one like in most sorts?
It is part of a larger program that can be found below.
import java.util.Random;
public class MyQueue implements IntegerQueue{
class Node{
Node next;
Integer data;
Node(Integer data){
this.data = data;
[Code]....
View Replies
View Related
Mar 7, 2014
here is the code i already have made;
import java.awt.*;
import javax.swing.*;
public class EX_7_2 extends JFrame
{
public EX_7_2()
{
setLayout(new BorderLayout(5, 10));
[Code] ....
View Replies
View Related
Jun 14, 2014
I copied this right out of oracle almost. And yet it won't draw.
ImageIcon salt = createImageIcon("icons/bathsalts.jpg");
/**
* @Override
*/
public void draw(Graphics g){
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(salt, getX(), getY(), null);
}
why draw image doesnt work for me. drawRect and circle are going just fine...
protected static ImageIcon createImageIcon(String path) {
try{
java.net.URL imgURL = ButtonPanel.class.getResource(path);
return new ImageIcon(imgURL);
} catch(RuntimeException e) {
System.out.println("Invalid file path");
}
return null;
}
View Replies
View Related
Feb 9, 2014
I have a Java application that was built by a third party and my task is to embed this in a web site. To do so I got an HTML snippet, a .JAR and da .DAT file that seems to be called by the app. I tested this locally on my machine and it works ok. After uploading to the web server I get an error message
NumberFormatException For input string: "i>>?<html>"(the question mark is actually upside down, the >> is really one character)
At first sight this looks like a common issue with UTF-8 file being delivered when the file itself holds only ANSI characters (or vice versa). So I made sure that the .HTM and the .DAT file are indeed stored in ANSI 8-bit (and not Unicode 16-bit) format. However, this does not solve the issue. The .HTM file itself also holds a ISO 8859-1 directive. The server is set to deliver UTF-8 by default. I cannot change this due to a huge lot of other dependencies.
So I am not sure if my suspicion is right - is it indeed a character set issue? Or is it something else?
The test file is on [URL] ....
View Replies
View Related
Mar 14, 2014
I have create a program that takes a random array which is created by starting from 0 and adding Math.random() (double between 0 and 0.999) n times, and calculates the weighted average of each position within a certain radius. I currently have a program that does this but i was wondering how to create one using a torus. The basic principle is the last element is now equal to the first element and when the first element updates its position it takes into account the difference between the other elements including some of the last elements in the array.
Heres the code so far that works for one iteration. After one the code is incorrect and calculates the wrong values. I think using a circular list or a ring buffer may work but i have little experience with either.
import java.text.DecimalFormat;
import java.util.Scanner;
public class Torus {
public static void main(String[] args) {
DecimalFormat df = new DecimalFormat("#.###");
[Code] ....
View Replies
View Related
Jun 13, 2014
The id variable is the problem Java Code: package com.cjburkey.games.boxee.objects;
import java.awt.Graphics;
import java.awt.Rectangle;
import com.cjburkey.games.boxee.GameState;
import com.cjburkey.games.boxee.resources.Images;
public class Block extends Rectangle {
[code]...
In the constructor, it returns corrent numbers, in the draw method, it returns 0. Why?
View Replies
View Related
Nov 30, 2014
I am having issue with jmenu popup in netbeans. It only sometimes works. Sometimes I don't get a java popup at all. Sometimes my File and Edit options are completely missing. This is what my code looks like.
import javax.swing.*;
public class menu {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
JFrame f = new JFrame();
f.setVisible(true);
[Code] .....
View Replies
View Related