How to change response’s status code from HttpAsyncContentProducer or defer response submission until content is ready

I have a class MyHttpAsyncHandler which implements HttpAsyncRequestHandler<HttpRequest>.
Once a request is received, it is handled via the handle(HttpRequest, HttpAsyncExchange, HttpContext) method, which I have overridden:

    HttpResponse response = httpExchange.getResponse();
    response.setHeader("Content-Type", String.valueOf(ContentType.APPLICATION_JSON));
    handleInternal(request, response, context);
    httpExchange.submitResponse(new BasicAsyncResponseProducer(response)); 

In the handleInternal method, after some processing, I define a BasicHttpEntity and assign to it a class I've written which extends BasicHttpEntity and implements HttpAsyncContentProducer, like this:

BasicHttpEntity entity = new MyResultEntity();
// Setting the status as 200, since this is the default case.

Let's say that during the execution of the request, the "back-end" might end-up with an error.
In the MyResultEntity, during produceContent, I can detect that error and I want to reply to the client with status code (500) and supply an informative error.

I have managed to supply an informative error, but I cannot manage to reply with a status code of 500.
Is there any way to do that?

What I have tried so far (and failed)
- Passing the response of handleInternal to the constructor of MyResultEntity, so as to set the status code using the setter. (Also, tried passing HttpExchage, getting response and setting its status to 500 after content is ready.)
- Extending the BasicAsyncResponseProducer (which contains the response object) and during produceContent detecting the error and setting the status code there.

It is also mentioned at the documentation that one can defer submission of response. How can one do this?

Am I missing something? Shouldn't there be a way to change the response's status code via the content producer if something goes wrong?

Additional info
The packages I am using are these:


WAMPServer 403 Forbidden (public) [duplicate]

I am getting this message: You don't have permission to access / on this server.

I have forwarded port 80 so I can get to it, but it's WAMP/Apache blocking me doing so.

Here is my current httpd.conf file:

Is there anything you can do to help me? I'm trying to access my website via my external IP (PC) and not via local (

Thanks (Here is the IP:

java.math.BigDecimal to Avro .avdl file

I'm having trouble writing an Avro schema for java.math.BigDecimal type, I tried the following:

  1. Based on Avro official doc, I know I need to define Logical Types myself to support BigDecimal, but that link gives example only in avsc, I'm trying to figure it out in avdl.
  2. Based on Avro doc and this example, I wrote below avdl:


protocol My_Protocol_v1 {

  record BigDecimal {
        @java-class("java.math.BigDecimal") string value;


But it's not working: This IDL schema compiles fine and can generate a Java class called BigDecimal, but I cannot really use the generated BigDecimal as java.math.BigDecimal, what's wrong? or How should I do it?

Thanks a lot

make htaccess rules just for some folders

i want to access videos in my site example:

so if i dont add ?token it will redirect to redirect.mp4

RewriteEngine on
RewriteCond %{QUERY_STRING} !=token
RewriteRule \.mp4$ [R=302,L]

i use this code but how to make it just for those folders:

video1, video2, video3

so what i want is to make rule just for mp4 files that are on video1, video2, video3 folder so they will play just if i add ?token at end of .mp4

XAMPP won’t open PHP files in directory (Mac)

All the servers are running correctly in XAMPP, and I when I run http://localhost the XAMPP page comes up. However when I try to run a php through xampp by accessing the directory where the file is stored, i.e.,


I get error 404. I've tried loads of different paths, but here is the path to the file in finder path image

Any ideas?


Rewrite Alternative use php instead of htaccess

I'm using a single index.php using switch...

My .htaccess is currently:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ index.php?page=$1 [NC,L]

Usually I would settle for this option but it will just end up in conflicts down the track with other stuff how can I replicate this in php taking it off Apache.

By the file format above the turns each case into

I can't find a simple guidance and how to achieve this in PHP and I know it is possible.

Allowing a trailing slash for a specific dynamic url?

I have done a 301 redirect for all trailing splash URLs in my htaccess file. Now I have a few dynamic URLs `**/** that need the splash. Note that in the end on the activate folder is a dynamic url that needs the splash.

How would I edit the .htaccess file? I have tried all sorts of codes, they dont seem to be working.

   IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

the dynamic url looks like this**/**

multiple language rewriting rules

I need to modify the rewrite rule of a blog inserted in a sub folder of the main site with language sub folder.

currently, this is the website behavior :

This part is working without any problem, but one blog is in a different section :

I would like to rewrite the blog to

The blog is using WordPress with WPML and in the english version I have a query string available (lang=en), for the french version, they is no query string available.

I would need to create a rule similar to :

 #English blog
 RewriteCond %{QUERY_STRING} lang=en
 RewriteCond %{REQUEST_URI} ^/blog/
 RewriteRule en/blog/$1

 #French blog
 RewriteCond %{QUERY_STRING} !lang=en 
 RewriteCond %{REQUEST_URI} ^/blog/
 RewriteRule fr/blog/$1

Thank you!

.htaccess re-write rule breaks on value change

I have the following rule in my .htaccess file and it works fine

RewriteRule ^eat/?([a-zA-Z0-9-]+)?/?([a-zA-Z0-9-]+)?/?([0-9]+)?/?([a-zA-Z0-9-]+)?/?$ /incl/pages/details.php?state=$1&city=$2&ID=$3&name=$4 [NC,L]

I need to modify the rule where the ID ($3) will be a 3 character alpha-numeric (always in caps) value and not a 3 digits as it is now.

I've tried but my rule stops working:

RewriteRule ^eat/?([a-zA-Z0-9-]+)?/?([a-zA-Z0-9-]+)?/?([A-Z0-9]+)?/?([a-zA-Z0-9-]+)?/?$ /incl/pages/details.php?state=$1&city=$2&ID=$3&name=$4 [NC,L]

What am I missing?

How to display users on a dashboard in a LAMP application? [on hold]

I am new to coding and have started learning via online tutorials and YouTube videos by mmtuts. I recently came across an issue and no video has been able to explain it well enough.

I have a well designed registration and login form built with phpMyAdmin, I have my database name as logintest and my table as user. I currently have 18 signed up users in my database, they have recorded information such as name, contact, username, payza email.

Now am trying to:

  • Display user 1 information on user 2, 3, 4, 5 dashboard

  • Display user 2 information on user 6, 7, 8, 9 dashboard

  • Display user 3 information on user 10, 11, 12, 13 dashboard

  • Display user 4 information on user 14, 15, 16, 17 dashboard