The HST and JWST are both mirror telescopes. There are many instruments on each, but the best known is the wide field and planetary camera (wfpc1), and its successors (wfpc2 and wfc3). These are all CCD cameras, and as such are based on the same basic technology that is found in many digital cameras, but there the similarity ends.
The camera is placed at the primary focus of the telescope. The telescope, therefore, acts as the main "lens". There are secondary optics, particularly in wfpc2 and 3 there are optics to correct the miscurvature of the main mirror. These optics are relay mirrors, not lenses.
Each camera is a one-off. Designed and built in-house by NASA. Compared to modern cameras, the resolution of the CCD is not so high. The original WFPC had an 800x800 pixel CCD, the WFPC2 had 4 800x800 pixel CCD sensors (at different pixel densities) If these seem low, remember that Hubble was designed and built in the '80s.
The cameras have to deal with a lot of things that the cameras we use don't. There are high-energy cosmic rays that can damage CCDs, and servicing required a shuttle launch. The CCDs are sensitive in a wide range of frequencies, from infrared to ultraviolet.
The latest camera, installed in 2009, has two light paths as shown, separating the visible from the IR imaging. As noted by Sean Lake in a comment, CCDs are read out by moving charge across the detector, infrared arrays read out individual pixels. IR arrays have more problems with stuck pixels or variable sensitivity across the array.
Schematic from the space telescope science institute.
So the cameras on Hubble, and the cameras that will be placed on JWST are distant relations of commercial digital cameras. They have no lenses, can see in a wider range of frequencies. The camera and its housing are also about 2m wide. However, the basic technology of converting an image into a digital file is shared between commercial digital cameras and the HST