I dunno much about linux programming, but here's how I'd go about it.
Have your JSP / Servlet make a call to the native function that actually changes the password. If there's not one to do this, you could try another method, such as:
Have your servlet make a native call to a C function which simply runs a shell script that you've written to change the details you require.
If you know a bit of C/shell this wouldn't take long at all.