Thursday, March 20, 2008

Encephalitis And Encephalopathy Difference



To upload a file we will use the libraries of struts. First What we are going to create a form that will take care of accessor methods for the file that we will save that type of FormFile struts.
 

package com.myapp.struts.action;

import org.apache.struts.action . ActionForm;
import org.apache.struts.upload.FormFile;

/
** * * @ author
r.sheshi
* / public class UploadFile
extends ActionForm {private
FormFile file;

public FormFile getFile () {
return file;}


public void SetFile (FormFile file) {
this.file = file;}



}

After defining the form to create JSPs that will do the upload.
 


\u0026lt;html:form action="/upload" enctype="multipart/form-data">
\u0026lt;html:file property="file" />
\u0026lt;html:submit value="carica" \u200b\u200b
/> \u0026lt;/ html: form>



The form must have the enctype set to "multipart / form-data" and use the tag html: file with propetrty set to "file" as mapped in our form. Now let's create our action.
 

/
** * * @ author
r.sheshi
* / public class
CaricaFileAction extends Action {



@ Override public ActionForward execute (ActionMapping mapping
,
ActionForm form, HttpServletRequest request
,
HttpServletResponse response) throws Exception {

DynaActionForm f = (DynaActionForm) form;
FormFile ff = (FormFile) f.get ("file");

return mapping.findForward ("success");}


}

The action we take the file from the bean that has struts valorizzato.Dopo taking the file you should go and inserilo blob in our field. Thus we create an object that we will take care of transferring data from the action of the Dao that ocuperà place.
 

/
** * * @ author
r.sheshi
* / public class
FileDto


{private int id;
private byte [] bytes;
private int size;
private String name;
private String contentType;


public void setBytes(byte[] bytes) {
this.bytes = bytes;
}

public byte[] getBytes() {
return bytes;
}
public void setId(int id) {
this.id = id;
}

public int getId() {
return id;
}


public void setName(String name) {
this.name = name;
}

public void setSize(int size) {
this.size = size;
}

public void setContentType(String type) {
this.type = type;


} public String getName () {
return name;}


public int getSize () {return size
;


} public String getContentType () {return type
;
}}



Now that we have our Dto that has a class variable array of bytes that will enhance it in action by using the method FormFile getFileData ().
 
DynaActionForm f = (DynaActionForm) form;
FormFile ff = (FormFile) f.get ("file");

FileDto FileDto dto = new ();
dto.setBytes (ff.getFileData ());
dto.setContentType (ff.getContentType ());
dto.setSize (ff.getFileSize ());
dto.setName (ff.getFileName ());


Now that we have enhanced our Dto passes it to the DAO to insert it into the database.
 

FileDao FileDao dao = new ();
dao.insert (dto);


Then in FileDao esguiamo operations for inseriento FILE in our table, which will have 4 fields (ID, FILE ( BLOB), name (VARCHAR), CONTENT_TYPE (VARCHAR)).

 

private String INSERT = "INSERT INTO VALUES FILE (?,?,?,?)";

public void insert (FileDto dto) {PreparedStatement ps
= Null;
Connection con = null;

try {con = getConnection


();
con.prepareStatement ps = (INSERT);
ps.setInt (1, dto.getId)
ps.setBytes (2 , dto.getBytes ());
ps.setString (3, dto.getName ());
ps.setString (4, dto.getContentType ());
ps.executeUpdate ();
} catch (SQLException ex)
{Logger.getLogger (FileDao.class.getName ())
. log (Level.SEVERE, null, ex);} finally {


try {if (ps! = null) ps.close ();
if (with! = null) con.close ();

} catch (SQLException ex) {Logger.getLogger
(FileDao.class.getName ())
. log (Level.SEVERE, null, ex);}


}}


At this point we will have our table inside the file and all information.




How do we get the file when we need it?



Now that we have our files in the database we create an action to display a list of files.
add a method to the Dao, which will make a select returning an ArrayList of Dto enhanced with only id and name.
 

listaFile public ArrayList () {
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;

DTOS ArrayList = new ArrayList ();



try {con = getConnection () ;
con.prepareStatement ps = (SELECT);
ps.executeQuery rs = ();
while (rs.next ()) {dto = new
FileDto FileDto ();
dto.setId (rs.getInt (1) )
dto.setName (rs.getString (2));


dtos.add (dto);


}} catch (SQLException ex) {Logger.getLogger
(FileDao.class.getName ())
. Log (Level.SEVERE, null, ex);} finally {


try {if (rs! = Null) ps.close ();
if (ps! = null) ps.close ();
if (with! = null) con.close ();
} catch (SQLException ex) {Logger.getLogger
(FileDao.class . getName ())
. log (Level.SEVERE, null, ex);}

}
DTOS return;}



Then we create a new Action that calls the listaFile method that will have as a return mettermo in our collection that request and then sliding it in jsp.
 

ListaFileAction extends Action {public class



@ Override public ActionForward execute (ActionMapping mapping, ActionForm form
,
HttpServletRequest request, HttpServletResponse
response) throws Exception {


FileDao FileDao dao = new ();
ArrayList DTOS dao.listaFile = ();
request.setAttribute ("list", DTOS)
return mapping.findForward ("list");


}}



Now that we have our list in jsp visualizziamola as a series of links to click that will call a action passing id file to download.
 


\u0026lt;html:html>
\u0026lt;logic:present name="lista">
\u0026lt;logic:iterate name="lista" id="dto">

\u0026lt;html: link action = "/ download" aramid = "fileid"
paramName = "dto" paramProperty = "id">

\u0026lt;bean:write name="dto" property="name"
/> \u0026lt;/ html: link>
\u0026lt;/ logic: iterate>
\u0026lt;/ logic: present>
\u0026lt;/ html: html>



proceed to create the action that handles the download of files by the ID that will pass in link will retrieve the file in the database by calling the Dao.
 
SELECT_BY_ID private String = "Select * from files where id =?"
public FileDto findById (int id) {
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
FileDto dto = FileDto new ();

try {con = getConnection


();
con.prepareStatement ps = (SELECT_BY_ID);
ps.setInt (1, id);
ps.executeQuery rs = ();
while (rs.next ()) {Blob blob =
rs.getBlob (2);
byte [] bytes = blob.getBytes (1, (int) blob.length ());
dto.setId (rs.getInt (1));
dto.setBytes (bytes);
dto.setName (Rs. getString (3));
dto.setContentType (rs.getString (4));





}} catch (SQLException ex) {Logger.getLogger
(FileDao.class.getName ())
. Log (Level.SEVERE, null, ex);} finally {


try {if (rs! = Null) ps.close ();
if (ps! = Null) ps.close (); if
(with! = null) con.close ();
} catch (SQLException ex) {Logger.getLogger
(FileDao.class.getName ())
. log (Level.SEVERE, null, ex);}

}
return dto;}




After calling the method findById () of the Dao we set the ContentType in the response depending on the type of file. In the attachment so that we set Header be downloaded on the local and the name of the file. Then get ServletOutputStream and write the byte array.

 

DownloadAction extends Action {public class



@ Override public ActionForward execute (ActionMapping mapping, ActionForm form
,
HttpServletRequest request, HttpServletResponse
response) throws Exception {

FileDao FileDao dao = new ();
String id = request.getParameter ("fileid");
FileDto dao.findById dto = (Integer.parseInt (id));

response.setContentType (dto.getContentType ());
response.setHeader ("Content-Disposition",
"attachment; filename = \\" "+ dto.getName () +" \\ "");

final ServletOutputStream response.getOutputStream out = ();
out.write ( dto.getBytes ());


return null;}


}

Friday, March 14, 2008

Bake Waffles (pancakes Of Hearts)

File Upload and Download The Song

Wednesday, February 27, 2008

Teeth Pulled Now White

Developer Java IDE Day


What is this?
arrives in Italy for the first time the international event that compares the most widely used Java IDE and their community.

JDeveloper (Oracle), NetBeans (Sun Microsystems), IntelliJ IDEA (JetBrains), send an evangelist of their core international development to confront each other.

present Speaker:

  • Roman Strobl (Sun Microsystems)
  • Paul Ramasso (Oracle)
  • Vaclav Pech (JetBrains)

Unfortunately, despite the commitment by both parties, it was not possible to have the presence of Eclipse .

How?
One time slot available for each IDE to show the potential of their environment than others.

key role is played by the public as they are provided posted spaces to ask questions directly to the international evangelist.

The final part of 'event will be dedicated to a reasoned debate on the future of development environments.

The event will be in English.

Cost:
The event is free, but registration is appreciated.

Organization:
IDE Day is organized by Jug Jug Genoa and Rome

When and where:
There are two dates: Genoa, and Rome on March 10, March 12
The event will take place in the afternoon , within the university.

For schedules, calendar and logistical information, please go to 's event.

Related Sites: http://www.ideday.org/



Sunday, November 11, 2007

Places To Ride Dirtnj

many different kinds of concept mapping

We are becoming more and more aware of the different uses of concept mapping. Learning-constructing knowledge, presenting, representing-reproducing models of realities, organizing shared knowledge models, are not the same kind of concept mapping. Each one can be made collaboratively, but only the former and the latter can be considered as strictly related to a pedagogical task.
In this "Concept maps as strategies for learning" web, as an example, we can see a cmap that tries to represent a piece of reality about a metabolic activity, here: http://www.eaa-knowledge.com/ojni/ni/602/strategies.htm .
Such cmaps need to "work", as they were engines (linking words are all influences among subsystems: "increase", "activate", "raises", "phosphorilates" etc.). Moreover, at the nodes of such a cmap, there are not concepts, but names of subsystems or objects.
As prof. Ahlberg maintains, these "pieces of reality" are not feasible to be represented as a whole hierarchical pattern. Functional relations in the real world aren't "concerned" with hierarchies. In fact that cmap has not a recognizable hierarchy of concepts. As a consequence, novel and unexpert people has not any chance to grasp the tinged meanings from that cmap. Secondly, a student can face such a cmap only after he has studied and masters deeply all the stuff. FOr this student, the representative task is a further difficulty that often doesn't add anything to the understanding of the knowledge domain.
It worths to remember that in similar attempts to represent how a real system works, we have often different symbolic languages that have been developed inside of each subject (mathematics, biochemistry, etc.), that are probably a better choice to represent similar complex domains.
On the other hand, when you use concept mapping as a metacognitive tool, and as a pedagogical language that helps you to mediate teaching-learning, the concept map change its features: there are more concepts, class names, that are related in a classificatory pattern; the cmap become an attempt to assure every concept an "epistemological" rank and role. The cmap constructed during the learning process don't say how everything influences dinamically every other subsystem, but how every concept is generated by the more inclusive or general concepts. This is a natural process that happens in the space of the mind of the learner, that is different from the processes that may occur in the real world. We can help our students if we are aware of this difference and if we don't ask them to make concept maps aimed at both representing the progress of individual epistemplogy and the mechanism-flow-chart of all the influences about a "piece of real world".

A few words should be written about concept maps as organizer of knowledge domains. This is a second process that interests the pedagogist, and that is subsequent to individual concept-mapping: how a knowledge domain can be organized, can be a viewed as a task for a learning community. This process happens in the space of a learning community. At this level collaborative learning can be very useful, both as a distance collaboration or as a local class peer interaction. But this organization purpose is again to be intended as a social learning process, not as a technical utility aimed to produce a final clear hypertext or a fine web interface (informative purposes).

This is just a reflection about our role of teachers and our view of concept mapping that is compatible with Ausubels-Novak theory and inclined to separate concept mapping as a process accompanying learning as a different one from representational or organizing purposes.