Mesoporous solid acids Ta3W7 and Nb3W7 were prepared from TaCl5 and NbCl5 with WCl6 in the presence of stearic acid (SA) via a sol-gel method, respectively. For comparison, mesoporous Ta3W7-P123 mixed oxides and mesoporous Nb3W7-P123 mixed oxides were synthesized in the same way. The catalysts were characterized through TGA, XRD, SEM, TEM, BET, and NH3-TPD. Experimental results showed that Ta3W7-SA and Nb3W7-SA exhibited several advantages such as higher activity, shorter preparation period, lower cost, stronger acid sites, and higher surface area, which had potential to be used as mesoporous heterogeneous catalysts in biodiesel production.