java,jquery,ajax,url-rewriting,struts2Related issues-Collection of common programming errors


  • Sotirios Delimanolis
    java
    In the below programpackage test;public class test {public static void main(String args[]){//System.out.println(2+3*4);int temp=0;temp+=temp++;System.out.println(temp);}}I do not understand why its giving me 0.Can any body please explain it?

  • hsalimi
    java php ruby django email
    I am using django. I just want to know is it possible to check if an email is a correct one, so that it will be definitely delivered (99.99%)? If the user entered an email like [email protected], it is technically a valid email but does not exist really. Can I detect such emails?

  • Sylvia Rosemond
    java constructor setter
    package cen.col.course.demo;import java.io.Serializable;public class Course implements Serializable {private static final long serialVersionUID = 1L; protected String code; protected String title; protected Professor professor;public Course( String code) throws InvalidDataException {super();setCode(code); }public Course(String code, String title ) throws InvalidDataException {this(code);setTitle(title); }public Course(String code, String title, Professor professor) throws InvalidDataException

  • celloplayer
    java exception try-catch
    If a method throws, say, an IOException, is there any negative effect from doing:catch (Exception ex){} instead ofcatch (IOException ex){}in my Java code?

  • user2424511
    java sockets concurrency
    I’ve got a pair of threads running a Socket and ServerSocket:runThreadA() {// Connects to B, or fails if B is not yet acceptingsocket.connect(); }runThreadB() {// Blocks until another thread connectsserverSocket.accept(); }Is there a way I can guarantee that B calls accept() and blocks before A calls connect()?

  • Ariel D. Moya Sequeira
    java keystore pkcs#11
    I’m using the following code to access the contents of a PKCS#11 smartcard from an Athena smartcard reader.Provider pkcs11Provider = new SunPKCS11(new ByteArrayInputStream (config.getBytes())); if (Security.getProvider(pkcs11Provider.getName()) != null) {Security.removeProvider(pkcs11Provider.getName()); }Security.addProvider(pkcs11Provider);KeyStore myKeyStore = KeyStore.getInstance (“PKCS11”, pkcs11Provider); myKeyStore.load(null, keystore_password.toCharArray());return myKeyStore;The problem

  • Arjan Tijms
    java mysql netbeans java-ee ejb
    Hey I made an EJB program and I created entity classes form my SQL database. Everything worked fine and it can connect to my database, but I get this error now for some reason. Im using glassfish v3 and netbeans ide 6.8WARNING: Can not find resource bundle for this logger. class name that failed: com.sun.gjc.common.DataSourceObjectBuilder SEVERE: jdbc.exc_cnfe_ds java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSourcemore random errors here.WARNING: RAR5038:Unexpected ex

  • cybye
    java performance memory
    I performed a short benchmark on a long array in java with quite strange results. It seems that sequential reads with random writes are faster – half the time – than random reads with sequential writes. Has anyone a clue why??Here are two methods that write an array of some longs (run with -Xmx2G or so) by random when reading sequentially and read sequentially when writing by random:import java.util.Random;public class Scratch { static Random random = new Random(); static long[] arr = new long[1

  • Adrian Shum
    java inheritance encapsulation
    public class test {public static void main(String[] args){new Person().printPerson();new Student().printPerson();} }class Student extends Person {public String getInfo(){return “Student”;} }class Person {private String getInfo(){return “Person”;}public void printPerson(){System.out.println(getInfo());} }The output to this is:Person PersonWhy is the second line not Student? The parent getInfo() is private but does that mean that the second call of printPerson() is prevented from finding the chil

  • JDeveloper
    java hibernate spring-mvc
    I am total new to Spring and hibernate. I donot know where I am doing mistake. I am using spring 4.0.2 and Hibernate 3 with eclipse and tomcat.Project structure :-LibrariesWeb.xml<?xml version=”1.0″ encoding=”UTF-8″?> <web-app xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns=”http://java.sun.com/xml/ns/javaee” xmlns:web=”http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd” xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd” i

  • Pool
    javascript jquery html
    I would like to display “password” as text in the password area, and when focused the box should become empty and allow normal password (starred out) input from the user.Currently I use the following method. Initially I display a text field showing password, when focused it is removed and replaced with a password field. Here is the jQuery:$(document).ready(function() {$(“#password”).focus( function() {$(“#pwd”).html(‘<input type=”password” id=”password” name=”password” value=”” />’);$(“#pa

  • user3003460
    jquery ajax django file-upload
    I am trying to build a small django pictures site using https://github.com/sigurdga/django-jquery-file-upload as a blueprint:My model is the following:class Picture(models.Model):test = models.SlugField(max_length=50, blank=True)slug = models.SlugField(max_length=50, blank=True)user = models.OneToOneField(User)file = models.ImageField(upload_to=”pictures”)def save(self, *args, **kwargs):self.slug = self.file.namesuper(Picture, self).save(*args, **kwargs)class PictureCreateView(CreateView):model

  • Schart
    javascript jquery google-chrome
    So I’ve tested this in Firefox as well and it works perfectly fine there, but when I opened my website in Chrome, none of the JS was working and I managed to find the chuck of code that is preventing it from loading. Here it is:/* LOAD NEW PAGE STREAM */ $(“.nextpage”).click(function(){var id = parseInt($(this).attr(“currentmax”), 10);$(“#allpostcontainer”).load(“/streampage.php?id=” + id);$(“.nextpage”).attr(“currentmax”, id+10);$(“.prevpage”).attr(“currentmax”, id+10);if (id => 10){$(“.prev

  • mmelear
    javascript jquery ajax
    I am trying to send an AJAX request to my spring backend. I am hitting the controller, and am successfully responding. I am new to javascript and AJAX, so I have hit a ceiling that I cannot get through. I am trying to call “done” on a successful callback, and am getting a very non-descript error. This is my console after I push “button”clicked testAjax. js:3 Uncaught SyntaxError: Unexpected token : product:1I haven’t created a product file, but when I go into it I get the object I am trying to

  • Alex Ford
    javascript jquery html events dom
    I am writing a jQuery plugin. In this plugin I wrap the existing BODY contents in a DIV and hide them.var $originalBodyContents = $(‘body’).wrapInner(‘<div>’).children(‘div’).hide();The plugin then appends its own overlay DIV to the BODY and does it’s plugin magic. When the user exits the plugin removes its overlay DIV, and unwraps them.$originalBodyContents.children().unwrap();This is working great, as you can see in this demo: http://jsfiddle.net/vKddB/1/However, if there are content scr

  • Miika L.
    jquery html ajax load
    I am using following code to load a html page inside a div,$(“#htmlViewer”).load(“conversion_test/to_convert_3264/”+getPageName(pageCount)+”.htm”, function(response, status, xhr) {if (status == “error”) {/* var msg = “Sorry but there was an error: “;$(“#error”).html(msg + xhr.status + ” ” + xhr.statusText); */jAlert(‘Unexpected Error : Please try again later’, ‘Alert’);pageCount–;}});In the above code I am getting only the HTML text but I am not getting CSS and the images in that page. To get t

  • John Conde
    javascript php jquery ajax
    I’m simply trying to read in a field from a text box, pass the value via ajax to PHP and then store the data in a mysql table. The table is already set up and ready to go, all I need is to insert values. Here is my js file var address = $(“input#email”).val(); //If submission is valid if(submitForm == “true”){$.ajax({ url: “bin/process.php”, type: “POST”, data: {email: address}, success: function(response) { $(‘#message’).html(response); }}); return false; }And then my PHP looks like this

  • duncan
    javascript jquery json google-maps-api-3
    Here’s my code:<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js”></script> <script>var API = “https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true”;var API = “https://maps.googleapis.com/maps/api/place/textsearch/json?query=chicken+greenvile+sc&sensor=true”;$.getJSON(API, function (data) {console.log(data); }); </script>If I comment out the second var API, I get a returned result

  • user1605822
    c# javascript jquery asp.net datetimepicker
    I am having trouble with displaying a date time on a page in a Textbox. See on Fiddle: http://jsfiddle.net/LkpPJ/5/Internet explorer and Firefox show: 2013-12-16T01:00Chrome shows: 12/16/2013 01:00 AMJavascript Console in Internet explorer and Firefox says:Error parsing the date/time string: Unexpected literal at position 2date/time string = 2013-12-16T01:00 timeFormat = hh:mm TT dateFormat =mm/dd/yyASP.NET C# Code:StartDatePicker.Text = dtStartDate.ToString(“yyyy-MM-ddTHH:mm”); <asp:TextBox

  • Fabrício Matté
    jquery autocomplete
    I’m trying to implement this web api autocomplete in a standard mvc app. http://techbrij.com/987/jquery-ui-autocomplete-asp-net-web-apiHere’s a screen grab from Firebug http://sdrv.ms/N0WkHPI’ve created a controller method and added the jquery script, but I keep getting a ‘JSON.parse: unexpected character’ error. I don’t see any unusual characters in my data.$(document).ready(function () { $(‘#txtSearch3’).autocomplete({source: function (request, response) {$.ajax({url: ‘/home/Get’,type: ‘GET’,c

  • Peter O.
    javascript ajax
    In my site I have:… <script type=”text/javascript” src=”https://www.google.com/jsapi”></script> …The script above is the Google script to load up other resources dynamically. (eg Google charts API) This works 99.99% of the time. However, I just got a client that for some reasons got his company restricting access to google.com.As a consequence of this my website simply threw a JavaScript error.Now I know how to handle that, and I can check if window.Google exists. but my questio

  • Neil

  • user3003460
    jquery ajax django file-upload
    I am trying to build a small django pictures site using https://github.com/sigurdga/django-jquery-file-upload as a blueprint:My model is the following:class Picture(models.Model):test = models.SlugField(max_length=50, blank=True)slug = models.SlugField(max_length=50, blank=True)user = models.OneToOneField(User)file = models.ImageField(upload_to=”pictures”)def save(self, *args, **kwargs):self.slug = self.file.namesuper(Picture, self).save(*args, **kwargs)class PictureCreateView(CreateView):model

  • mmelear
    javascript jquery ajax
    I am trying to send an AJAX request to my spring backend. I am hitting the controller, and am successfully responding. I am new to javascript and AJAX, so I have hit a ceiling that I cannot get through. I am trying to call “done” on a successful callback, and am getting a very non-descript error. This is my console after I push “button”clicked testAjax. js:3 Uncaught SyntaxError: Unexpected token : product:1I haven’t created a product file, but when I go into it I get the object I am trying to

  • Munzilla
    javascript ajax html5 websocket accessibility
    One of the major requirements for accessibility standards such as WCAG is that the web site or application displays without the use of javascript or provides some sort of non JS alternative. I did some initial research and couldn’t find much information on this in regard to websockets. Should I assume websockets are treated similar to AJAX?

  • Miika L.
    jquery html ajax load
    I am using following code to load a html page inside a div,$(“#htmlViewer”).load(“conversion_test/to_convert_3264/”+getPageName(pageCount)+”.htm”, function(response, status, xhr) {if (status == “error”) {/* var msg = “Sorry but there was an error: “;$(“#error”).html(msg + xhr.status + ” ” + xhr.statusText); */jAlert(‘Unexpected Error : Please try again later’, ‘Alert’);pageCount–;}});In the above code I am getting only the HTML text but I am not getting CSS and the images in that page. To get t

  • John Conde
    javascript php jquery ajax
    I’m simply trying to read in a field from a text box, pass the value via ajax to PHP and then store the data in a mysql table. The table is already set up and ready to go, all I need is to insert values. Here is my js file var address = $(“input#email”).val(); //If submission is valid if(submitForm == “true”){$.ajax({ url: “bin/process.php”, type: “POST”, data: {email: address}, success: function(response) { $(‘#message’).html(response); }}); return false; }And then my PHP looks like this

  • Helena Standaert
    javascript ajax angularjs
    I’m building an angular app where I have a ‘public transportation’ section and I want to get directions from the google api. I seem to get a valid url – when I enter the url in my browser, it returns the json. But I get an error when user $.ajax.Urlhttp://maps.googleapis.com/maps/api/directions/json? origin=Assenede,%20Belgi%C3%AB&destination=Industrieweg%20232,Gent- Mariakerke,belgium&sensor=false&departure_time=1343641500&mode=transitFunction in angular controller$scope.getDire

  • user1871612
    javascript jquery ajax
    To ask about getscripthtml Code as follows:<!DOCTYPE html PUBLIC “- / / W3C / / DTD XHTML 1.0 Transitional / / EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html><head> <title>jQuery GetScript</title> <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”></script> <script type = “text / javascript “> $(document). ready(function () {$getScript (‘script.js’, function (jd) {$.each (test, function (index, valu

  • Rohan Kumar
    php jquery ajax json
    Hi friends can anyone me for this plz. im new to this chapter..i am trying to get JSON format value from PHP but while im running i got this output “SyntaxError: JSON.parse: unexpected characte”.. i think i had done mistake in php conversion …plz help me friends my .html file<html> <head><script src=”http://code.jquery.com/jquery-1.8.3.min.js”></script><title>Display Page</title> </head> <body><button type=’button’ id=’getdata’>GetData.<

  • Sumurai8
    php forms .htaccess mod-rewrite url-rewriting
    i have problem with mod rewritei made htaccess to convert url from php to htmland every thing finebut problem is some file i dont need to convert like form.phpthis is my htaccessRewriteCond %{REQUEST_URI} !^(.*)form.php(.*)$ RewriteCond %{REQUEST_URI} !^(.*)sitemap\.xml(.*)$ RewriteCond %{THE_REQUEST} ^[A-Z]+\s([^/]+)\.php\s RewriteRule .* %1.html [R=301,L] RewriteRule ^([^/]*)\.html$ $1.php RewriteCond %{ENV:REDIRECT_STATUS} 200 RewriteRule ^.*$ – [L] RewriteRule ^index.php$ http://%{http_host}

  • PeeHaa
    php .htaccess codeigniter url url-rewriting
    I tried to make my website’s URL cleaner(and SEO friendly) by removing the index.php from my URLs but unexpected results happend, this is my .htaccess file: <IfModule mod_rewrite.c> <IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /### Canonicalize codeigniter URLsRewriteRule ^(site(/index)?|index(\.php)?)/?$ / [L,R=301]RewriteRule ^(.*)/index/?$ $1 [L,R=301]# Removes trailing slashes (prevents SEO duplicate content issues)RewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.+)/$ $1

  • Kev
    asp.net iis-7 url-rewriting web-config
    I am using IIS7’s URLRewrite feature to hide the .aspx extension in my ASP.NET WebForms application’s URLs. I’m using the following configuration:<rule name=”WebFormsToMVC” stopProcessing=”true”> <match url=”^(.*?)\.aspx\?*?.*$” /> <conditions> <add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” /> <add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” /> </conditions> <action type=”Rewrite” url=”{R:1}” /> </rule>

  • Carl Manaster
    php apache .htaccess mod-rewrite url-rewriting
    My last post was met by smarmy, unhelpful “answers” (comments), so i’ll get right to it:if I have an htaccess file like so:RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.phpRewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ – [L] RewriteRule ^([^/]+)/([^/]+)$ /index.php?page=$1&subject=$2 RewriteRule ^([^/]+)$ /index.php?page=$1 [L]how can I allow for other url variable names and values to be handled… say for instance I want

  • SalesforceQueries
    javascript url-rewriting salesforce remoting visualforce
    I am getting an error when I use JavaScript remoting and have my URLReWriter turned on on my Force.com SIte. The error does not occur when using JavaScript Remoting with the URL ReWriter turned off.The error is as followsException Error parsing json response: ‘Unexpected token <‘. Logged in? I’m confused as to why this is occuring. If I have no checks for being logged in in my URL ReWriter (or visualforce page) why should this occur?Has anyone ever come across something similar to this befor

  • SlovaN
    regex mod-rewrite url-rewriting apache2
    I’m playing with apache rewrite_mod (Apache/2.2.17 Win32) and encounter very weird behave of rewriteRule.My script primarily rewrite infinite filter parameters named f1 .. f<infinity> from nice url and in loop adding them as query variables, add path as query, and page number.It works flawlessly, but if I add one another rule (last rule in script)RewriteRule ^(.+)\.html$ /index.php?path=$1.html [QSA]which is for another cases, it change execution of rewriterule at s

  • Rohit Pande
    url-rewriting htaccess
    As per the answer provided in How to create custom URL routes? I have created the rewrite rule using the same function provided.add_action( ‘init’, ‘wpse26388_rewrites_init’ ); function wpse26388_rewrites_init(){add_rewrite_rule(‘gallery/([0-9]+)/?$’,’gallery?custom_gallery_id=$1′,’top’ ); }After the flushing of the rules .htaccess file was having the following rule :RewriteRule ^gallery/([^/]+)/?$ /wordpress/gallery?custom_gallery_id=$1 [QSA,L]upto this point everything was fine then I

  • G. M.
    url-rewriting add-rewrite-rule
    I am using URL rewrite like this page: unexpected problem in url rewriteIt works without any problem, but when I try to use the same rules for nested page, it doesn’t work. Say, I have two pages named page-a and page-b. page-a is parent for page-b. Now I want to catch the passed variable. The URL structure will be:page-a/page-b/ page-a/page-b/var1/ page-a/page-b/var1/var2/ page-a/page-b/var1/var2/var3/So, I created three rules. The full code is as follows:add_filter( ‘query_vars’, ‘wpse26388_que

  • Paul
    asp.net database url url-rewriting url-routing
    I have single aspx page to view product details. i have stored url of each product in database against each productid. Now please guide me how we can generate http url from url text stored in database dynamically which is bookmarkable also.Basically i am looking for url that stakeoverflow generate at runtime.Thanks,Paul

  • Martin
    asp.net-mvc url-rewriting url-routing
    Im trying to make a very simple application that lets my client create their own pages. The hard part is to let them create thir own URL.Client need to fill in:Page name (ex. About us). Page description (ex. We are a big company). Page URL relative (ex. /About)When client enter this information and save, it should be saved in the database.I can easily create a controller named “Page” which takes a value “ID” and when a user enters “www.someurl.com/Page/1” the newly created page pops up.But what

  • Roman C
    java parameters struts2 interceptor
    I am trying to understand the use of ActionMappingParametersInteceptor class in Struts2. Looking in the API:This interceptor sets all parameters from the action mapping, for thisrequest, on the value stack. It operates exactly likeParametersInterceptor, only the parameters come from theActionMapping, not the ActionContext.getParameters() method.Is there a case where an ActionMapping class might contain a different set of request parameters than the ones I am getting from the ActionContext.getPar

  • aksamit
    java jsp struts2 struts
    I am following the Struts 2 Tutorial – Using Struts 2 TagsSo far everything have been working as expected until I added the following to index.jsp:<s:url action=”hello” var=”helloLink”><s:param name=”userName”>Bruce Phillips</s:param> </s:url> <p><a href=”${helloLink}”>Hello Bruce Phillips</a></p>Expected result is that the anchor-link (Hello Bruce Phillips) should be substituted with corresponding URL for hello.action with parameter userName encod

  • sjr
    java spring struts2 javabeans
    I’m developing a web-app using Struts 2 with a Spring 3 backend. I’m using Spring aop:proxy beans to handle my session beans rather than the Struts 2 SessionAware interface. Everything was working fine until I have an Action that is running under the Struts ExecAndWait interceptor. Because this interceptor in effect runs my action under a seperate thread, when I come to try and access my proxied session bean, I get a BeanCreationException/IllegalStateException. Is there another “spring way” that

  • DarkKnightFan
    ajax jsp struts2 servlet-filters session-timeout
    I am making ajax calls from my JS methods to invoke the action class’s methods in the following manner:$.getJSON(“treeDemo_!getRootNode?appId=” + applicationId, function () {}).success(function (e) {}).error(function (jqXHR, textStatus, errorThrown) {alert(textStatus);}).complete(function () {});Session configuration in my web.xml looks like this<session-config><session-timeout>1</session-timeout> </session-config>Now when the session expires after 1 minute, the ajax call

  • Roman C
    java jsp struts2 struts ognl
    I have a situation where in Struts application I have select tag and some values inside it<select name=’locale’><option value = “DATA1”>FR_DATA1</option><option value = “DATA2”>FR_DATA2</option><option value = “DATA3”>FR_DATA3</option><option value = “DATA4”>FR_DATA4</option><option value = “DATA5”>FR_DATA5</option></select>now problem is that when I submit the form the value passed to setter method of the action form is lab

  • Miguel Ribeiro
    javascript json exception struts2
    I have this JSon string received from an AJAX call: {status:OK,addresses:[0,1,2,3,4,5]}To convert it to a JSon object I have this line:var jsonObj = eval(jsonString);But an exception is thrown! This one has no message in the exception variable. I also tried using{“status”:”OK”,”addresses”:[0,1,2,3,4,5]}And, yet again, an exception is thrown but saying that an unexpected character ‘&’ was found.I’m using Struts2 and the JSon is received from an action.Any help will be appreciated. Thank you

  • buzzsawddog
    java struts2
    For some reason I am getting the following error message:Developer Notification (set struts.devMode to false to disable this message): Unexpected Exception caught setting ‘claimForm.payableEvents[1].totalHours’ on ‘class com.somedomain.application.action.claimreimbursement.ProcessSaveClaimFormAction: Error setting expression ‘claimForm.payableEvents[1].totalHours’ with value ‘[Ljava.lang.String;@54f242c1’ Developer Notification (set struts.devMode to false to disable this message): Unexpected Ex

  • Roman C
    java list jsp struts2 ognl
    This is the form I am using to repopulate the ArrayList<form method = “POST” action = “addItemsToTemplate”><s:iterator value = “myQuestions” var = “quizItem” status=”key”><s:textfield name = “quizItem.question”/> </s:iterator><input type = “submit” value = “submit”/> </form>This is the action class public class QuizTest extends ActionSupport{public String execute(){List<Question> q= myQuestions;System.out.println(myQuestions);return “success”;}public

  • Dennis
    javascript struts2 escaping
    I read some struts2 variable in javascript as follows:<javascript type=”text/javascript”> var data='<s:property value=”simulationInfos”/>’; <javascript>If my simulationInfos contains single quote ‘, I get the error : unexpected identifier.therefore, I tried to escape the quote as follows:var data='<s:property value=”simInfos” escapeJavaScript=”true”/>’; and var data='<s:property value=”simInfos” escapeHTML=”true”/>’;I get the error: Attribute escapeJavaScript (or e

  • Andrea Ligios
    hibernate struts2 struts ognl
    Struts 2 is giving a strange behavior that the commercial,productCategory objects is not set on on form submission.It happens in some cases like these.Other fields are getting set properly Most of the cases struts 2 is setting the custom objects very well and even for complex objects like List inside a object but in this case it is giving strange behavior.Can somebody help in this.Can i debug the struts 2 code to check why it is not setting the property.If possible let me know the steps Hibern

Web site is in building