Showing posts with label webapp. Show all posts
Showing posts with label webapp. Show all posts

Saturday, October 10, 2015

Web Application for File Upload with streaming

This gives you an entire working example (worth 1000 user manual pages) http://www.codejava.net/java-ee/servlet/apache-commons-fileupload-example-with-servlet-and-jsp .... I have tested it and put in https://github.com/vernetto/WebFileUploader (just git clone it and run it).

Here the user guide of Apache FileUpload module:

http://commons.apache.org/proper/commons-fileupload/using.html

Create a webapp

Download commons-io jar http://commons.apache.org/proper/commons-io/download_io.cgi and commons-fileupload jar http://commons.apache.org/proper/commons-fileupload/download_fileupload.cgi and place them in WEB-INF/lib

Well actually rather than putting here snippets of code, here is the whole NON-Streaming example https://github.com/vernetto/WebFileUploader and here the STREAMING example https://github.com/vernetto/WebFileUploaderStreaming

I have tested with a 4GB file and memory occupation on the server (and Garbage Collection) was really minimal... transfer speed was also decent (say 2 minutes for a 4GB file....).

Here https://raw.githubusercontent.com/vernetto/WebFileUploaderStreaming/master/WebFileUploaderStreaming.war you can download the war file directly.



Monday, March 25, 2013

weblogic keep generated java from jsp

in your weblogic.xml, enter this:
<weblogic-web-app  xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <jsp-descriptor>
        <keepgenerated>true</keepgenerated>
  <working-dir>/opt/oracle/apps/wlobelix/tmp</working-dir>
        <backward-compatible>true</backward-compatible>
  <debug>true</debug>
    </jsp-descriptor>



Make sure that /opt/oracle/apps/wlobelix/tmp exists, and is writable by the unix user running WLS.

Redeploy, restart - eventually before restart delete the weblogic server tmp directory.In the Configuration tab of the webapplication, make sure the checkboxes are active:





BIG WARNING: remember to delete the content of the /opt/oracle/apps/wlobelix/tmp folder at each new deployment, otherwise you might not get the latest JSP version.

Saturday, January 26, 2013

WebLogic: developing Web Applications

Developing WebLogic Web Applications has proven quite tricky to me; and I remember that it was tricky 8 years ago, last time I did it.... so not much seems to have changed.

As a rule, when things act weird:

- clear cookies
- rm -rf $DOMAIN_HOME/servers/$SERVER_NAME/tmp/
- rm -rf $DOMAIN_HOME/servers/$SERVER_NAME/cache/
- update webapp
- restart server



In Tomcat I never had all these problems.... mystery....

Thursday, January 24, 2013

WebLogic secured Web Application

web.xml:

here I define a role "webuser" to protect my resources:


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 id="WebApp_ID" version="2.5">
 <display-name>PVWebApp</display-name>

 <welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.htm</welcome-file>
  <welcome-file>index.jsp</welcome-file>
  <welcome-file>default.html</welcome-file>
  <welcome-file>default.htm</welcome-file>
  <welcome-file>default.jsp</welcome-file>
 </welcome-file-list>

 <security-constraint>
  <web-resource-collection>
   <web-resource-name>Success</web-resource-name>
   <url-pattern>/index.jsp</url-pattern>
   <http-method>GET</http-method>
   <http-method>POST</http-method>
  </web-resource-collection>
  <auth-constraint>
   <role-name>webuser</role-name>
  </auth-constraint>
 </security-constraint>


 <login-config>
  <auth-method>FORM</auth-method>
  <realm-name>default</realm-name>
  <form-login-config>
   <form-login-page>/login.jsp</form-login-page>
   <form-error-page>/error.jsp</form-error-page>
  </form-login-config>
 </login-config>

 <security-role>
  <role-name>webuser</role-name>
 </security-role>

</web-app>



weblogic.xml:

here associate the role "webuser" to a principal myGroup


<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic 810-web-jar.dtd">

<weblogic-web-app>

  <security-role-assignment>
   <role-name>webuser</role-name>
   <principal-name>myGroup</principal-name>
  </security-role-assignment>

</weblogic-web-app>



I have tried to record the creation of the myGroup and myUser in WebLogic, but I got a message "A security change to a role, policy, user, group or credential mapping was made, but this change was not recorded"

Manually, just click on Security Realms, myrealm, Users and Groups, groups, new, create myGroup, then Users, create myUser and assing it the group "myGroup".

With WLST:
connect('Pierluigi', 'weblogic1', 't3://myhost.com:7001')
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider('DefaultAuthenticator')


group = 'proton_group'
atnr.createGroup(group,group)

user = 'proton_user'
password= 'proton_password'
atnr.createUser(user,password,user)
atnr.addMemberToGroup(group,user)



Tuesday, May 1, 2012

OSB Web Applications

ALSB Logging wlservername_/xbuslogging
ALSB Publish wlservername_/xbuspublish
ALSB Resource wlservername_/sbresource
ALSB Routing wlservername_/xbusrouting
ALSB Subscription Listener wlservername_/alsb-uddi
ALSB Test Framework wlservername_/sbtestservice
ALSB Transform wlservername_/xbustransform
ALSB WSIL wlservername_/sbinspection.wsil
DMS Application_11.1.1.1.0 wlservername_/dms_11.1.1.1.0
WS Transport Async Applcation wlservername_/alsb/ws/_async
bea_wls_cluster_internal wlservername_/bea_wls_cluster_internal
wsil-wls wlservername_/inspection.wsil
XBus Kernel wlservername_/httpTransport

plus an entry for each HTTP proxy service in this format:

XBus Kernel wlservername_/full/path/to/ProxyService