Daniel and Samuel Sledden mocked Judge Beverley Lunt on Facebook after admitting drug dealing charges.
Daniel, 27, posted within 90 minutes of leaving Burnley Crown Court, while Samuel, 22, made offensive remarks 40 minutes after he left the dock.
Judge Lunt said the pair had not "learned any responsibility".
The judge said: "The question I have to ask myself is this, if I had not known their real feelings at being in court would I have accepted their remorse and contrition, and suspended the sentence. And the answer is of course not.
"Each of the posts indicate they have not changed at all. They have not taken on board anything or learned any responsibility."
Both men, from Accrington had admitted supplying cannabis from the family home in Hopwood Street between May and September 2014 and were initially given two-year jail sentences, suspended for two years.
Daniel Sledden used obscene language in a message he posted online and said he could not believe his luck at getting a suspended sentence.
It "beats the three year jail, yes pal", he wrote.
His brother also used profanity when celebrating: "What a day it's been Burnley Crown Court..nice two year suspended".
Earlier this month, Judge Lunt told the court she did not want to read the messages out which contained "offensive sexual elements".
Two drug dealing brothers taken back to court for mocking a judge on Facebook when she decided not to jail them have now been jailed for two years.