This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!

Andrey Dmitriev

Ranch Hand
+ Follow
since Jan 04, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Andrey Dmitriev

   Hello everyone

   The following code:



In this variant


  console shows:
0
Thread[pool-1-thread-1,5,main]
InterruptedException 1
1
Thread[pool-1-thread-1,5,main]
0
Thread[pool-1-thread-2,5,main]
1
Thread[pool-1-thread-2,5,main]
value2 is 0

  and in this



    0
Thread[pool-1-thread-1,5,main]
1
Thread[pool-1-thread-1,5,main]
value1 is 0
0
Thread[pool-1-thread-1,5,main]
InterruptedException 2
1
Thread[pool-1-thread-1,5,main]

    I cant understand clearly, how its working.
    It turns out that:
In first case:
1. count1 started for execute in thread1.
2. count2 interrupts the execution of count1.
3. count1 resumed in thread1.
4. count2 executed in thread2.

In second case:
1. count1 started for execute in thread1.
2. count1 executed in thread1.
3. count2 started for execute in thread1. (?).
4. count1 interrupts the execution of count2.
5. count2 resumed in thread1.

   I cant understand:
1. Why in first case two threads have applied, and in second case - one thread.
2. Why in second case count1 interrupted the execution of count2 after count1 terminated computations.  





Bear Bibeault wrote:That likely means your URL is malformed. What happens when you try to load that URL directly into the browser?



  When I try to load that URL directly into the browser  In Safari this URL forwards me on correctly page.   But, doing this in Chrome, i get the empty page...


Bear Bibeault wrote:Also, why is your URL absolute, versus server-relative? You could run into CORS issues.



      I have used relative URL in AJAX, but withot success.  

But in html-form-submit it works properly: for example


    I'm confused....


Bear Bibeault wrote:

Bear Bibeault wrote:Does the Networking Panel show that a request is generated?




 Failed to load resource: the server responded with a status of 404 ()
   And developer console does not show any problems
   Noting is changed

   And there is no errors in log.

   

Bear Bibeault wrote:One problem I see (besides the code formatting which is all over the place) is that you are not stopping the default action of the form submission. If you want to make an Ajax call rather than actually submitting the form, you either need to call the preventDefault method of the event, or return false from the event handler.




   To make is so, for example?




Why aren't you using jQuery to do all this? Makes it tons easier.



  Yes, i'll try it later
   Greetings to all!

    Code in JSP:


 In Servlet




   But ajax does not  fulfil post method.



    yes, i m sorry. I have changed code on:






    And I  use other plugin



  In console:  The origin server did not find a current representation for the target resource or is not willing to disclose that one exists
for:   /jsfiles/jquery-1.4.2.min.js

  and:

  can't find variable $

Tim Moores wrote:Separate the script tag that loads jQuery from the script tag with the JavaScript code. See the description of the src attribute in https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script



  I did this, but result is the same
   jquery-code does not work.

   I see only button - but it does not work
     Greetings to all

     Have a problem with using of jquery in jsp-page

Code in JSP
     

    in Pom


and



  I suppose, the problem is in plugin.
  But I cant understand, in what it consists.


     Greetings to all!

     JSP code:


in Servlete-code



    IO-code in ImageService-class


  As a resulte:
1. In log:
- stream to servlet without problem
- Buffer is not null
- Temporary is not null
- request is not null
- fileOutputStream is not null

2. In "newimage"-directory new file is creating. For example: "Picture147".
  But this file IS EMPTY....

  So, html/js send  a file on server,  servlet receives it with request ("stream to servlet without problem"), ImageService serialize it and creates a new file.
  But serialized data is not saved in this new file!

  Additionally:  size of image-file, wich i try to save from web-page to server has a size: 250 × 188

   




1 month ago

Tim Holloway wrote:

Instead, when you have a web server, the file contents are embedded in the HttpResponse stream and the client decides what to do with that data. As I said, the client might choose to save the content in a file, but it might choose to open it in an application. The server cannot control what the client will do. Only the client can make that decision.



  Thanks. And could you advice me any example of code?
1 month ago

Dave Tolls wrote:

You'd normally loop over the input stream, reading into a byte buffer, then writing that buffer out to the output stream.  Keep looping until the number of bytes read comes back as -1.



   And really I did not do that?

 
1 month ago