Posts

Showing posts with the label Struts

MVC Design Pattern java

  MVC Design Pattern:-           MVC Design Pattern made with three components (Layer ).            M ---> Denotes Model components            V ---> Denotes View components            C ----> Denotes Controller components Model component:-           In Model component we represent data objects. Model component is being manipulated and present to the user. View component:-          View component represent data on html pages which is manipulate in the Model component. Controller components:-          Controller component handle all the things from handle request and response to client.

is actionservlet thread safe

ActionServlet is controller in Model View Controller design pattern for web applications. ActionServlet is not thread safe There is only a method named getRequestProcessor is synchronized. Code of this method is below :- /** * <p>Look up and return the {@link RequestProcessor} responsible for the * specified module, creating a new one if necessary.</p> * * @param config The module configuration for which to * acquire and return a RequestProcessor. * * @exception ServletException if we cannot instantiate a RequestProcessor * instance * @since Struts 1.1 */ protected synchronized RequestProcessor getRequestProcessor(ModuleConfig config) throws ServletException { // :FIXME: Document UnavailableException? RequestProcessor processor = this.getProcessorForModule(config); if (processor == null) { try { processor = (RequestProcessor) RequestUtils.applicationInstance( config.getControllerConfig().getProcessorClass()); } catch (Exception e) { throw new UnavailableException...

Interceptor in struts2 java

Interceptor Definition:-                      In struts2, An Interceptor is an interface under the com.opensymphony.xwork2.interceptor package. An Interceptor extends the Serializable Interface. An interceptor is a stateless class that follows the interceptor pattern.     Interceptor give the choice to write code that can be invoke before and after the execution of an action. Interceptor also have the facility to stop an action from executing. Interceptors provide developers a way to encapulate common functionality in a re-usable form that can be applied to one or more Actions.

How to copy file using FromFile in Struts java

public String copyFile(FormFile formFile, String destinationFolder,             String outputFileName) throws IOException {         byte[] data = new byte[1000];                 InputStream input = formFile.getInputStream();         String filename = formFile.getFileName();         new File(destinationFolder).mkdirs();         File file = new File(destinationFolder, outputFileName);         FileOutputStream output = new FileOutputStream(file);         try {             try {                 while (true) {                  ...

Recent Post

Recent Posts Widget