Search Results

Search found 14958 results on 599 pages for 'non technical'.

Page 68/599 | < Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >

  • Handling file upload in a non-blocking manner

    - by Kaliyug Antagonist
    The background thread is here Just to make objective clear - the user will upload a large file and must be redirected immediately to another page for proceeding different operations. But the file being large, will take time to be read from the controller's InputStream. So I unwillingly decided to fork a new Thread to handle this I/O. The code is as follows : The controller servlet /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub System.out.println("In Controller.doPost(...)"); TempModel tempModel = new TempModel(); tempModel.uploadSegYFile(request, response); System.out.println("Forwarding to Accepted.jsp"); /*try { Thread.sleep(1000 * 60); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ request.getRequestDispatcher("/jsp/Accepted.jsp").forward(request, response); } The model class package com.model; import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.utils.ProcessUtils; public class TempModel { public void uploadSegYFile(HttpServletRequest request, HttpServletResponse response) { // TODO Auto-generated method stub System.out.println("In TempModel.uploadSegYFile(...)"); /* * Trigger the upload/processing code in a thread, return immediately * and notify when the thread completes */ try { FileUploaderRunnable fileUploadRunnable = new FileUploaderRunnable( request.getInputStream()); /* * Future<FileUploaderRunnable> future = ProcessUtils.submitTask( * fileUploadRunnable, fileUploadRunnable); * * FileUploaderRunnable processed = future.get(); * * System.out.println("Is file uploaded : " + * processed.isFileUploaded()); */ Thread uploadThread = new Thread(fileUploadRunnable); uploadThread.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } /* * catch (InterruptedException e) { // TODO Auto-generated catch block * e.printStackTrace(); } catch (ExecutionException e) { // TODO * Auto-generated catch block e.printStackTrace(); } */ System.out.println("Returning from TempModel.uploadSegYFile(...)"); } } The Runnable package com.model; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; public class FileUploaderRunnable implements Runnable { private boolean isFileUploaded = false; private InputStream inputStream = null; public FileUploaderRunnable(InputStream inputStream) { // TODO Auto-generated constructor stub this.inputStream = inputStream; } public void run() { // TODO Auto-generated method stub /* Read from InputStream. If success, set isFileUploaded = true */ System.out.println("Starting upload in a thread"); File outputFile = new File("D:/06c01_output.seg");/* * This will be changed * later */ FileOutputStream fos; ReadableByteChannel readable = Channels.newChannel(inputStream); ByteBuffer buffer = ByteBuffer.allocate(1000000); try { fos = new FileOutputStream(outputFile); while (readable.read(buffer) != -1) { fos.write(buffer.array()); buffer.clear(); } fos.flush(); fos.close(); readable.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("File upload thread completed"); } public boolean isFileUploaded() { return isFileUploaded; } } My queries/doubts : Spawning threads manually from the Servlet makes sense to me logically but scares me coding wise - the container isn't aware of these threads after all(I think so!) The current code is giving an Exception which is quite obvious - the stream is inaccessible as the doPost(...) method returns before the run() method completes : In Controller.doPost(...) In TempModel.uploadSegYFile(...) Returning from TempModel.uploadSegYFile(...) Forwarding to Accepted.jsp Starting upload in a thread Exception in thread "Thread-4" java.lang.NullPointerException at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:512) at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:497) at org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:559) at org.apache.coyote.http11.AbstractInputBuffer.doRead(AbstractInputBuffer.java:324) at org.apache.coyote.Request.doRead(Request.java:422) at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:287) at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:407) at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:310) at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:202) at java.nio.channels.Channels$ReadableByteChannelImpl.read(Unknown Source) at com.model.FileUploaderRunnable.run(FileUploaderRunnable.java:39) at java.lang.Thread.run(Unknown Source) Keeping in mind the point 1., does the use of Executor framework help me in anyway ? package com.utils; import java.util.concurrent.Future; import java.util.concurrent.ScheduledThreadPoolExecutor; public final class ProcessUtils { /* Ensure that no more than 2 uploads,processing req. are allowed */ private static final ScheduledThreadPoolExecutor threadPoolExec = new ScheduledThreadPoolExecutor( 2); public static <T> Future<T> submitTask(Runnable task, T result) { return threadPoolExec.submit(task, result); } } So how should I ensure that the user doesn't block and the stream remains accessible so that the (uploaded)file can be read from it?

    Read the article

  • making text boxes non editable in html

    - by Sachindra
    i am trying to make a text box no editable for the users. I tried using this code and it works. Any ramifications??? I mean do u suggest the use of this code or it may cause trouble for me in future??? <input type="text" name="west" value="fixed value" readonly />

    Read the article

  • REST services - exposing non-data "actions"

    - by ctacke
    I understand how to use REST for doing general entity interactions - using urls names to map to entities and the HTTP verbs to map to actions on those entities. But what is the generally accepted way of looking at "actions" more like RPC? For example, let's say I want to send a command for the device to reset? There's no real "entity" here or do I do something like POST to http://mydevice/device/reset?

    Read the article

  • How to declare different non-JPA annotations on embedded classes

    - by e99y
    @Embedded public class EmbedMe { private String prop1; private String prop2; } @Entity public class EncryptedEmbedded { @Embeddable private EmbedMe enc; } I am current using Jasypt for encryption. Is there a way to indicate that the @Embeddable in EncryptedEmbedded will use @Type(value = "newDeclaredTypeHere") per attribute (prop1, prop2)? Thanks in advance... ;)

    Read the article

  • ASP.Net website makes browser load unwanted (non-referenced) plugins

    - by alec0001
    I've found that some of my ASP.Net web apps prompt the browser to load plugins that I'm not explicitely using and certainly haven't deliberately referenced in the project settings. Two that come to mind are for MS MediaPlayer and the "SVG Viewer for Netscape". The only commonality I've determined so far is that the two sites/apps affected both use Master pages (nested in some cases). We don't use SVG file types (just the normal mix of jpg/gif/png) and no video/audio (not yet anyway). Can anyone provide a hint as to where the references for these might be creeping in? e.g. Is it a server-level include? Or a .Net runtime default when using master pages? Does anyone else even experience this, or is it just me? No urgency, I'd just like to remove it if possible. Thanks. Al

    Read the article

  • C++ : Declaring the array size with a non-constant variable

    - by Jérôme
    I always thought that when declaring an array in C++, the size has to be a constant integer value. For instance : int MyArray[5]; // correct or const int ARRAY_SIZE = 6; int MyArray[ARRAY_SIZE]; // correct but int ArraySize = 5; int MyArray[ArraySize]; // incorrect Here is also what is explained in The C++ Programming Language, by Bjarne Stroustrup : The number of elements of the array, the array bound, must be a constant expression (§C.5). If you need variable bounds, use a vector(§3.7.1, §16.3). For example: void f(int i) { int v1[i]; // error : array size not a constant expression vector<int> v2[i]; // ok } But to my big surprise, the code above does compile fine on my system ! Here is what I tried to compile : void f(int i) { int v2[i]; } int main() { int i = 3; int v1[i]; f(5); } I got no error ! I'm using GCC v4.4.0. Is there something I'm missing ?

    Read the article

  • Client validate non-model bound checkbox while using MVC 2 jQuery Validation

    - by Justin Saraceno
    Have: Using ASP.NET MVC 2, DataAnnotationsModel based server validation, and client validation with jQuery. Anything in my model is validated perfectly on the client with jQuery based validation (jQuery.validate and MicrosoftMvcJQueryValidation.js). Need: Adding an additional HTML <input type="checkbox" id="terms" /> to my form. I need jQuery validation to require that this checkbox is checked AND somehow hook it in with whatever jQuery client script MVC is automagically controlling. Yes, I know it won't validate on the server side, but I don't need or want it to. Seems like it should be simple but I'm new to MVC, a total beginner at jQuery, and my searches have been coming up blank. Any help would be appreciated!

    Read the article

  • .net c# datagridview populating with non database data/setup

    - by flavour404
    Hi, I have never used the datagridview in any other scenario other than one where it is populating by a database so suddenly my mind goes blank... I have 10 tubes, each with 8 vertical positions within it, so I have a 10 by 8 grid basically. Each has of those slots has (or not) an image in a folder. How do I get a datagridview to reflect this information, draw a grid, check the folder and if the image exists paint it white, and if not paint it red? Sorry it if sounds a little odd, thanks, R.

    Read the article

  • Pasting non-text data into browser-based apps

    - by John
    Imagine I want a user to be able to copy-paste a selection of pixels from MSPaint into a browser-based app. Is this possible using JavaScript in any current browsers? Will it become possible in HTML5? If not, is it feasible using something like Flex/Silverlight, or is it simply not possible at this time, and you'd have to save a file and manually upload it?

    Read the article

  • Using non-Railsy route to prepopulate a form

    - by user94154
    I have many instances of a Rails model, Post. When viewing an individual post, I'd like to create a form to create a child of Post called Comment. I'd like to prepopulate this form with a hidden tag that contains the post_id which is the foreign key in Comment. The Railsy way to do this is to create a fancy-ish route such as: /comments/new/post/:post_id However, this gunks up the routes file and doesn't leave much flexibility. Let's say I want to create a link somewhere else that prepopulates a different attribute of the form...then I'd have to add another route for this. So I think I'm going to create urls like this on /posts/show/:id: /comments/new?comment[post_id]=<%= @post.id %> This way I can add any other attributes as I need. I know the plus side associated with this, now what are the downsides?

    Read the article

  • glReadPixels() returning non-accurate value

    - by max
    I'm trying to implement the flood fill algorithm. But glReadPixels() is returning float RGB values of a pixel which are slightly different from the actual value set by me, causing the algorithm to fail. Why is this happening? Outputting returned RGB values to check. #include<iostream> #include<GL/glut.h> using namespace std; float boundaryColor[3]={0,0,0}, interiorColor[3]={0,0,0.5}, fillColor[3]={1,0,0}; float readPixel[3]; void init(void) { glClearColor(0,0,0.5,0); glMatrixMode(GL_PROJECTION); gluOrtho2D(0,500,0,500); } void setPixel(int x,int y) { glColor3fv(fillColor); glBegin(GL_POINTS); glVertex2f(x,y); glEnd(); } void getPixel(int x, int y, float *color) { glReadPixels(x,y,1,1,GL_RGB,GL_FLOAT,color); } void floodFill(int x,int y) { getPixel(x,y,readPixel); //outputting values here to check cout<<readPixel[0]<<endl; cout<<readPixel[1]<<endl; cout<<readPixel[2]<<endl; if( readPixel[0]==interiorColor[0] && readPixel[1]==interiorColor[1] && readPixel[2]==interiorColor[2] ) { setPixel(x,y); floodFill(x+1,y); floodFill(x,y+1); floodFill(x-1,y); floodFill(x,y-1); } } void display() { glClear(GL_COLOR_BUFFER_BIT); glColor3fv(boundaryColor); glLineWidth(3); glBegin(GL_LINE_STRIP); glVertex2i(150,150); glVertex2i(150,350); glVertex2i(350,350); glVertex2i(350,150); glVertex2i(150,150); glEnd(); floodFill(200,200); glFlush(); } int main(int argc,char** argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowPosition(100,100); glutInitWindowSize(500,500); glutCreateWindow("Flood fill"); init(); glutDisplayFunc(display); glutMainLoop(); }

    Read the article

  • II7 integrated mode MVC deploy 404 not found on "non-Index" actions

    - by majkinetor
    Hello. Once deployed parts of my web-application stop working. Index-es on each controller do work, other then that yields 404. I understand that nothing particular should be done in integrated mode. I don't know how to proceed with troubleshooting. Some info: App is using default app pool set to integrated mode. WebApp is done in net framework 3.5. I use default routing model. Along web.config in root there is web.config in /View folder referencing HttpNotFoundHandler. OS is Windows Server 2008. Any help is appreciated. Thx.

    Read the article

  • Compact Framework Non Culture Specific Exception Messages

    - by Ian
    Hi Everyone, I have created an application in Compact Framework 2.0 This application is being used in many various counties and cultures. My Issue is that any and all exceptions are logged, but they are appearing in the culture of the device, in some cases this means i am unable to read them. Any help or suggestions will be appreciated Thanks

    Read the article

  • howto create a new Date() in Javascript from a non-standard date format

    - by Michel
    hi, i have a date in this format : dd.mm.yyyy when i instantiate a javascript date with it, it gives me a NaN in c# i can specify a dateformat, to say: here you have my string, it's in this format, please make a Datetime of it. is this possible in javascript too, and if not, is there an easy way? i would prefer not to use a substring for day, substring for month etc. because my method must also be capable of german, italian, english etc dates.

    Read the article

  • Loop through non-integer rows using SQL

    - by Jesse
    I know how to accomplish my task with .NET, but I wanted to do this just in SQL. I need to loop through all of the rows where the primary key is somewhat arbitrary. It can be a number or a series of letters, and probably any number of unusual things. I know I could do something like this... DECLARE @numRows INT SET @numRows = (SELECT COUNT(pkField) FROM myTable) DECLARE @I INT SET @I = 1 WHILE (@I <= @numRows) BEGIN --Do what I need to here SET @I = @I + 1 END ...if my rows were indexed in a contiguous fashion, but I don't know enough about SQL to do that if they're not. I keep coming across the use of "cursors," but I come across just as much reading about avoiding cursors. I found this SO solution but I'm not sure if that's what I'm needing? I appreciate any ideas.

    Read the article

  • Creating non-framework calsses in CakePHP

    - by Affian
    I'm making a tournament manager in CakePHP 1.3 and I have a tournament controller which is fine but I want to implement a interface that can be used to define how a tournament runs. the controller needs to load a concrete class that implements the TournamentStyle interface that defines how the tournament works. At the end of a round the TournamentStyle is used to calculate the scores and winners and generate the next round of matches. That gives me a .php file for the interface and other files for the various styles. My question is: where would I put these files and how would I load them into my tournament controller?

    Read the article

  • how to search for a term only in non test files

    - by dorelal
    I use ack and I like it. However from time to time I need to search for something in my code base and I want to ignore all the files residing in test directory. Basically all the files which have test in their absolute path should be not included in the search. How do I achieve that? I am willing to have a custom bash script. Something like ack_no_test "application" - search for "application" in all files but ignore files residing in test directory

    Read the article

  • Replace non-html links with <A> tags

    - by tombazza
    I have a block of code that will take a block of text like the following: Sample text sample text http://www.google.com sample text Using the preg_replace_callback method and the following regular expression: preg_replace_callback('/http:\/\/([,\%\w.\-_\/\?\=\+\&\~\#\$]+)/', create_function( '$matches', '$url = $matches[1]; $anchorText = ( strlen($url) > 35 ? substr($url, 0, 35).\'...\' : $url); return \'<a href="http://\'. $url .\'">\'. $anchorText .\'</a>\';'), $str); Will convert the sample text to look like: Sample text sample text < a href="http://www.google.com"http://www.google.com< /a sample text My problem now is that we have introduced a rich text editor that can create links before being sent to the script. I need to update this piece of code so that it will ignore any URLs that are already inside an tag.

    Read the article

  • Catch requests to non-existent classes (not autoload)

    - by Spot
    Is there a manner in which to catch requests to a class which does not exist. I'm looking for something exactly like __call() and __static(), but for classes as opposed to methods in a class. I am not talking about autoloading. I need to be able to interrupt the request and reroute it. Ideas?

    Read the article

  • Need a MYSQL query to compare two tables and only output non matching results

    - by ee12csvt
    I have two tables in my database, one contains a list of items with other information on these items. The other table is contains a list of photographs of these items. The items table gives each item a unique identifier,which is used in the photographs table to identifier which item has been photographed. I need to output a list of items that are not linked to a photograph in the second table. Any ideas on how I can do this?

    Read the article

  • C# (non-abstract) class to represent paths

    - by user289770
    I'm looking for a C# class that represents a file system path. I would like to use it (instead of strings) as the data type of variables and method arguments (top reasons: type safety, concat-proof, logical comparisons). System.IO.Path provides most of the functionality I want, but it is abstract. System.IO.FileInfo, as I understand, performs IO operations to do its job. I only want a wrapper for the path string. Thanks!

    Read the article

  • How does a java compiler resolve a non-imported name

    - by gexicide
    Consider I use a type X in my java compilation unit from package foo.bar and X is not defined in the compilation unit itself nor is it directly imported. How does a java compiler resolve X now efficiently? There are a few possibilities where X could reside: X might be imported via a star import a.b.* X might reside in the same package as the compilation unit X might be a language type, i.e. reside in java.lang The problem I see is especially (2.). Since X might be a package-private type, it is not even required that X resides in a compilation unit that is named X.java. Thus, the compiler must look into all entries of the class path and search for any classes in a package foo.bar, it then must read every class that is in package foo.bar to check whether X is included. That sounds very expensive. Especially when I compile only a single file, the compiler has to read dozens of class files only to find a type X. If I use a lot of star imports, this procedure has to be repeated for a lot of types (although class files won't be read twice, of course). So is it advisable to import also types from the same package to speed up the compilation process? Or is there a faster method for resolving an unimported type X which I was not able to find?

    Read the article

< Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >