Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have Tomcat with two (Foo and Bar) applications on it (two .war's). It is the same application but different versions.
Each of them has endpoint /test.
GET foo/test - return "Hello World"
GET bar/test - return "Hello Universe"
What I need.
All incoming requests by default coming on foo.
When Tomcat receives incoming request foo/test?param=42 - it should redirect it to bar. And it should call bar/test?param=42.
Redirections rules should be based on URL parameters. All param=42 -> bar, all another ->foo
That sounds like something you would code in a servlet Filter.
Or, since this is Tomcat, if you want to do it externally from the application, I believe you could do it with a Valve.
You might want to study up on both, before making a decision.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I m develloping a web application, in which I have to show, let's say, a list of tasks.
What I need to do is once a user open a task (i.e open it in his browser), it gets deleted of all the others users lists or it shows that the task is taken, no one can open a task that is already opened by someone else.
In addition, I need that once a user close a task (for example user closes his browser) , it get re-added to other users tasks list.
How can I do that please ? WebSocket in client side ? Any other -better- choices? How to manage this in the server side ?
Thank you
There is two solutions (that I know of) for your problem :
Ajax (and Long Poll)
Using Ajax you can poll the server every X seconds for data necessary to implement the behavior you described. This may work but it is not a recommended way to go. read why on this thread.
WebSocket
Just like a socket you'd use on a desktop application (hence the name), you can open a WebSocket connection (not an HTTP one), keep it as long as needed and close it only when you're done with it. This is the preferred way to have data flowing constantly between a client and a server. It is also supported by almost every major browser out there
There is other technologies such as WebRTC and Server-Sent Events, but considering your description of the problem, those might not be what you're looking for.
Off-topic : And I'm not sure why your question has been downvoted, looks legit to me.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am not a Java pro. I need to enable my completed java applications to ONLINE-Versions. Kindly give me the simplest way.
I have tried to go the JSP and Servlet way, but seems exceedingly tiresome,there surely ought to be a direct way.
When you use a typical web application what do you think is happening? You're in a browser and it's displaying some pages. You click around and some server does some work, for example Amazon shows you a list of books you could buy, the server is passing data to the browser for it to display.
That's a big difference from your current Java Application where everything is happening in the same computer.
This split between the UI part of the application, in the Browser, and the server part that's doing the real business is one reason why Web programming is so different from simple Java programming.
Servlets and JSPs are the traditional Java way of doing things, but modern web apps make much greater use of JavaScript for all the UI and all the Java (or any other server technology) does is provide the data displayed by JavaScript.
Bottom line: Sorry, but there is a whole lot more to learn. My recommendation would be to grit your teeth and forget about what you've done so far and start studying JavaScript and HTML.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm not sure if the title says what I needed. But that's the best way I can put it.
My requirement: I want to check if a series of engine numbers (of vehicles) are registered with the local transportation authority. They have provide a web-interface for this task, but I can only check for a single engine number at once. Usually I need to check over 200 numbers. So, its a humongous task to check each one individually.
A couple of years ago, I have created a small standalone python script to do this automatically using web scraping, but now I want to do this on a server.
A user gives all the numbers in the text file which they upload/paste the contents in to a text field. Then I'll have to submit the form on the transportation website (using web scraping) for each number and display a final status for all of them.
What I want to know is how to do this on a server? What technologies could be helpful. I'm comfortable with Java & JavaScript. I don't know PHP (But i can learn if needed). I don't have slightest Idea how to do this on server side. Any Ideas and Help is greatly appreciated.
Thanks.
Java has a library called JSoup, which provides a mostly-familiar api that uses css selectors.
And obviously there are built-in functions that can get you the html from a given URL.
Put those together and you've got a server-side scraper
[edit]
Your question, on a re-read, isn't just about scraping -- it's about how to automatically submit an html form from within Java to an external server. This is an interesting question, one I've wondered myself.
this may be an answer: How to send post form with java?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
What is the proper way to implement user permissions in the filter in a java web app using MVC?
All my jsp files are located in the directory WEB-INF.
All requests are processed in a Servlet (you have to send a request by a GET or POST query calling
get-->/controller?command=particularcommand
using POST you need to specify the command parameter in another way).
So access to them is performed by commands. Also commands are used to perform other operations.
I have 4 types of users and 2 enums containing names of commands (Ajax and usual). I use command pattern and command factory.
So the main idea of the question is what is the proper way to organize permissions in the filter - collections or xml files or smth else.
BTW, the idea is not to use any frameworks. Only jsp can be used. That's the resctriction of my task.
Filter or intercepting Filter is a very good idea to check the request permission. It is also the proper way. Just redirect to main page or send 401 error if permission is not granted.
Anyway i suggest you to use modern frameworks like Spring MVC with Spring security and other great features.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I need to extract answers from 500 stackoverflow questions at a time, but suddenly I read this error on Eclipse console:
Server returned HTTP response code: 503 for URL:
https://stackoverflow.com/search?q=lucene+IndexWriter+registerMerge%28
and if I use browser after that I read this message:
There are an unusual number of requests coming from this IP address.
To protect our users, we can't process any more requests from this IP address right now.
We'll restore access as quickly as possible, so try again soon.
I do this for a research work. Am I violating some SO rule?
The message is straightforward: you're screenscraping StackOverflow, and SO doesn't want you doing that.
If you still want to spider the site then just rate-limit your accessing, maybe make one request every 100ms or even 250ms instead of 500 at a time (which is what I assume you're doing).