2 Answers
2

Geoserver serves maps while OpenLayers displays them. None of those two can do routing maps as of this writing. What you need is something to do the shortest path computation.

I think it would be best to study PostGIS and pgrouting as @simplexio has suggested. PostGIS is a spatial database while pgrouting extends PostGIS by adding geospatial routing capabilities. Here's a workshop that combines PostGIS, OpenLayers and pgRouting. It should be enough to get you started. Good luck!

Your question is quite open ended, but I assume what you are after would be some sort of routing engine.

GeoServer and OpenLayers do not have routing capabilities built in (someone can correct me if I am wrong though), so you would need some sort of routing engine on your server such as RouteWare, or you could use a web routing service such as the Google Directions API.