Hello, so I'm a student and in one of my projects I have to capture the image of a client from a WebCamp and then save it on the database. Now, I'm having some problems and doubts. I've found some videos where they use the library JMF (Java Media Framework), but with J2SE. My project and all my classes are in Servlets/JSP with Struts2. So, I'm not sure how to adjust it.

For example: What I did in my jsp, was this:

<h1>Elegir la cámara Web disponible</h1>
<s:select list="camaras" name="camaras" headerKey="-1" headerValue="Select Value"></s:select>

Then, in my Action:

public class MascotaAction extends ActionSupport{
    //private ArrayList<Camara> camaras;
    private List<String> camaras;
    private Camara camara;

    @Action(value="AComboJSON", results={@Result(name="success",location="/mascota.jsp")})
    public String ListadoComboJSON() throws Exception{
        Vector listaCamaras = null;
        listaCamaras = CaptureDeviceManager.getDeviceList(null);

        for (int i = 0; i < listaCamaras.size(); i++) {
            CaptureDeviceInfo info = (CaptureDeviceInfo)listaCamaras.get(i);
            String nombreCamara = info.getName().toString();
            camaras = new ArrayList<String>();
            if(nombreCamara.indexOf("image")!=-1 || nombreCamara.indexOf("Image")!=-1){
                Camara cam = new Camara();

        return SUCCESS;

    /*public ArrayList<Camara> getCamaras() {
        return camaras;

    public void setCamaras(ArrayList<Camara> camaras) {
        this.camaras = camaras;

    public List<String> getCamaras() {
        return camaras;

    public void setCamaras(List<String> camaras) {
        this.camaras = camaras;

    public Camara getCamara() {
        return camara;

    public void setCamara(Camara camara) {
        this.camara = camara;


This first intent is just to show in a combo the available devices. I hope you can help me. Now, I was following this video on YT: https://www.youtube.com/watch?v=K49nVuFE_BI&index=79&list=PL54E2FA87AF018A55 and trying to change it for Struts2.

Recommended Answers

All 2 Replies

you can't. JSP runs on the server, you'd end up using the webcam (if there is one, there shouldn't be) on the server.
Which is of course not what you want...

You're going to have to use some sort of client side technology instead. Flash, Java applets, html5, Silverlight, etc..

Nice try at some free publicity for your product!
I'm sure there's a reason why you didn't mention that it costs between 8 and 12 THOUSAND dollars.
Caveat emptor.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.