Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!

Jack Tauson

Ranch Hand
+ Follow
since Mar 27, 2014
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jack Tauson

Stephan van Hulst wrote:I'm pretty sure that Postman has some kind of control where you can enter request parameters and if the request is a GET request, Postman will encode the parameters in the URL for you. You shouldn't put parameters in the URL manually.

However, it appears that you are performing a request that modifies your application state. You must not use a GET request for this, but instead a POST or PUT request. The data that you want to store in the database should not be part of the URL, but rather of the request body.



Thank you.

The data that you want to store in the database should not be part of the URL, but rather of the request body.


I was thinking about this. I would appreciate if I could get some more advise on this.

While calling the download endpoint, I am calling the stored procedure in my code and that needs parameters and hence I decided to use it like GET request. I mean, the data which is the part of the URL is not directly getting saved into the database. Could you tell me if this scenario is still good or do I still need to consider sending the data as a part of request body? Thanks again !
3 weeks ago

Paul Clapham wrote:

Jack Tauson wrote:Should I do it like this (encode \ as %5C):

%5CABC10PCS_2015AA%5C



Well, yes and no. You should just be URL-encoding all of the parameter values of your URL, is what you should be doing. Not asking whether specific characters should be encoded.



I believe when you say "URL-encoding of all of the parameter values", you mean I should do it at the time of calling the end point from UI? OR is there a way to do it in POSTMAN client as well? Thanks !
3 weeks ago

Stephan van Hulst wrote:What happened when you tried it?



This worked fine. The eclipse didn't complain. Characters showed up as \ in the database.
3 weeks ago

Rob Spoor wrote:

Dave Tolls wrote:Looks like '\' hasn't been encoded.


I'm quoting this because it's still true.



Should I do it like this (encode \ as %5C):

%5CABC10PCS_2015AA%5C
3 weeks ago

Stephan van Hulst wrote:There's also a spurious space after the '=' of the p_user_application part of the query string.



Not sure. Made some changes and it's still throwing same error:




I used to send the parameters in same fashion before without any issues.




Also tried removing space from the values of parameters p_in_project_title and p_in_project_description. No luck so far.
3 weeks ago
I am making a POST call like this from POSTMAN (screenshot below):



And as soon as I am making a call, I am getting following error:



Not sure why it is happening. My database guy just updated the stored procedure name that I am calling by calling the /download endpoint so I just updated the stored procedure name and a parameter name in the code. It used to work fine before making any changes.

I researched online and some people mentioned that it could be tomcat issue so I switched from version 9 to 8.5.58 locally in eclipse and it's still happening. What might be wrong?
4 weeks ago

Ron McLeod wrote:In addition to including Content-Type: application/octet-stream header, you also need to provide a header which provides the filename; something like:
    Content-Disposition: attachment; filename="fileName.zip"



Thanks. In my first chunk of code,I forgot to include the following ( I have edited my original post) for everyone's reference:



I wonder how do I include above stuff in my second chunk of code?

1 month ago

Paul Clapham wrote:Well, in the first chunk of code you use ".../custom_documents/" + user + "/" + filename and in the second chunk you use ".../custom_documents/" + filename + "/" + user. Those are both actual code accessing the file system. The first is correct and the second is wrong, according to both the error message and the description you gave before the first chunk of code. It is very simple to fix the second chunk of code to build the file path in the correct order.

It's true that your endpoint looks like ".../filename/user" but it's unfortunate, because your correct chunk of code extracts the filename and user parts and puts them back together in the correct order.



Thanks. That fixed the error after making the following changes. However, it's not downloading the actual zip file. It downloaded a file of type "File" with name "JACK" and when I opened it in notepad ++ it was full of garbage characters. What is going wrong here?

1 month ago
I have the following endpoint working fine if I run it locally like the following :



Here, I am running FileDownloadApp named application locally on eclipse which is deployed on tomcat.

-downloadFile is the name of the endpoint as shown below

-fileName.zip is the file residing inside /mnt/nfs/myfolder/prod/documents/custom_documents/JACK directory.

Basically, it's inside the JACK directory on Windows. The whole thing is meant for Unix environment but I am testing it on Windows and hence the pathname is like that.




However,when I converted it to the following - used Resource interface, I am getting the following error:




1 month ago

Dave Tolls wrote:Good job.

So does your endpoint return all the data in one go?



Thanks!
Yeah, it does. I guess as long as I am getting data back to the browser, I  will be able to download the data from the above logic.

Dave Tolls wrote:Yes, somewhere you need to remember what the query parameters were, either in the session or in the page.

Also, it doesn't have to be a flag....it can be another endpoint. It's up to you how to structure it.



I was able to achieve this using JavaScript only. Found this tutorial very useful:

https://www.youtube.com/watch?v=eicLNabvZN8&t=103s

Dave Tolls wrote:Well, it can be the same one with a flag or similar indicating what format to return the results in.



Hmm, so what I understood is that, for the table, I can leave it as JSON response.

For Export to Excel button, I could have a flag to call the same web service with a flag indicating that CSV data is needed. However, at the point, when button is about to click, in order for me to call the same webservice, I would have to remember somewhere in my UI application, maybe in the form of sessionStorage, the name of all the parameters selected/supplied by the user so that I can make a different call.

Are you also suggesting something similar to what I explained above?

Dave Tolls wrote:Can you show us a diagram of the architecture?
That is, what the different parts are and which bits you control?

I'm a bit confused as to which part is yours and which is some external service you call, and is not controlled by you.

Because, if I had control of this I would just have the download button request an excel copy off the server, and the server would redo the query, but instead of returning JSON it would create an XLSX file instead (or CSV if we're talking straight data, which would be dead easy).



Sure. Please find the UI diagram I just drew on a paper below:




So at first, user sees only the Advanced Search section until the Search and Clear buttons. After selecting things from the drop-down boxes, user clicks on the Search button. This calls a search web service in the backend. A new table shows up with Search results (81702) as shown in the diagram above.

Below the table, I have Export to Excel button. That's where I am having issues since the records are so big and jQWidget I am using is unable ot handle more than 600 records. So they are asking me to host their source code file on my server and so on and so forth.

When you say the following:

Because, if I had control of this I would just have the download button request an excel copy off the server, and the server would redo the query, but instead of returning JSON it would create an XLSX file instead (or CSV if we're talking straight data, which would be dead easy).



I would have to make another webservice call when user clicks on the Export to Excel button, right?
On my User Interface, there is an Advanced Search section where user selects 5-7 things from the 5-7 different dropdown menu and based on these parameters, a web service is called. The webservice returns the search results in a JSON format and those records are displayed in a tabular format in the User Interface.

Something like this : http://jsfiddle.net/jqwidgets/6HRU8)

So I have a Download button below the tabular section where all records are displayed, just like shown in the jsfiddle above.

If I have to download the records in excel format as soon as user clicks the download button, is there something better than using jQXwidgets that is used in the JSFiddle and in my code as well?

The reason I want to go away from jqxwidget is that they are asking to supply a URL hosted on my RHEL server and that’s causing issues to me in setting up virtualhost on Apache etc. The reason they are asking is that the records are around 2000 or more and to handle the load I need to have their solution on my server.

Tim Holloway wrote:

Dave Tolls wrote:Doesn't have to be multiple users, as in people, just multiple threads.

If more than one thread at a time accesses this code then something will eventually break.
All it would take is for one thread to close the connection before another thread tries to use either it or the Session value from lines 70-78.



Or for two threads to try to use the connection at once and thus corrupt the connection's internal state.



I see. How about using addressing multiple people accessing the application at the same time by adding synchronized block as shown below:

2 months ago