JSP to ASP.NET can any one answer!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ozzii
    New Member
    • Jan 2007
    • 37

    JSP to ASP.NET can any one answer!

    Hi,

    Is it possible to convert the following JSP code to ASP.NET?

    Code:
    <%--
    
           
        Exactly 2 parameters need to be set
        1) format
        2) filename
    
    --%>
    
    <%@page import="java.io.*,java.net.URLDecoder,emaxon.formats.MolImporter,emaxon.struc.Molecule"%>
    <%
    try {
        // Retrieving GET/POST parameters
        String format = request.getParameter("format");
        if(format == null) {
        	throw new Exception("Format needs to be specified.");
        }
        String filename = null;
        String molstring = null;
        if((filename = request.getParameter("file")) == null) {
        	if((molstring = request.getParameter("mol")) == null) {
    	    throw new Exception("Structure needs to be specified.");
    	}
        }
    
        // Setting content type
        String type = format.indexOf(":") == -1 ? 
    	    format : format.substring(0, format.indexOf(":"));
        response.setContentType("image/" + type);
    
        // Creating the molecule
        Molecule mol = null;
        if(molstring == null) {
            // Reading the file
            File f = new File(filename);
            MolImporter mi = new MolImporter(f,"");
            mol = mi.read();
        } else {
            // Reading the posted SMILES string
    	mol = MolImporter.importMol(molstring);
        }
        
        // Calculate the coordinates if needed (for example
        // if the input is SMILES)
        if(mol.getDim()==0) {
            mol.clean(2, "O1");
        }
        
        // Generating the image
        byte[] b = mol.toBinFormat(format);
        ServletOutputStream outs = response.getOutputStream();
        outs.flush();
        outs.write(b,0,b.length);
        outs.close();
    } catch(Throwable t) {
        t.printStackTrace();
    }
    %>
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by ozzii
    Hi,

    Is it possible to convert the following JSP code to ASP.NET?

    Code:
    <%--
     
     
    Exactly 2 parameters need to be set
    1) format
    2) filename
     
    --%>
     
    <%@page import="java.io.*,java.net.URLDecoder,emaxon.formats.MolImporter,emaxon.struc.Molecule"%>
    <%
    try {
    // Retrieving GET/POST parameters
    String format = request.getParameter("format");
    if(format == null) {
    	throw new Exception("Format needs to be specified.");
    }
    String filename = null;
    String molstring = null;
    if((filename = request.getParameter("file")) == null) {
    	if((molstring = request.getParameter("mol")) == null) {
    	 throw new Exception("Structure needs to be specified.");
    	}
    }
     
    // Setting content type
    String type = format.indexOf(":") == -1 ? 
    	 format : format.substring(0, format.indexOf(":"));
    response.setContentType("image/" + type);
     
    // Creating the molecule
    Molecule mol = null;
    if(molstring == null) {
    // Reading the file
    File f = new File(filename);
    MolImporter mi = new MolImporter(f,"");
    mol = mi.read();
    } else {
    // Reading the posted SMILES string
    	mol = MolImporter.importMol(molstring);
    }
     
    // Calculate the coordinates if needed (for example
    // if the input is SMILES)
    if(mol.getDim()==0) {
    mol.clean(2, "O1");
    }
     
    // Generating the image
    byte[] b = mol.toBinFormat(format);
    ServletOutputStream outs = response.getOutputStream();
    outs.flush();
    outs.write(b,0,b.length);
    outs.close();
    } catch(Throwable t) {
    t.printStackTrace();
    }
    %>
    It is possible to achieve the same functionality in ASP.NET. What you need to do is write down your program logic in pseude code then try try to write the ASP code for it.

    Comment

    • ozzii
      New Member
      • Jan 2007
      • 37

      #3
      Originally posted by r035198x
      It is possible to achieve the same functionality in ASP.NET. What you need to do is write down your program logic in pseude code then try try to write the ASP code for it.
      I simply need to convert the above jsp script to asp. I am not familiar with JSP syntax which is why i am unable to convert the logic my self.

      Does anybody have the microsoft java language conversion assistant tool to convert the above code for me? I know its available to download for free but i need visual studio 2005 package to run it!

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by ozzii
        I simply need to convert the above jsp script to asp. I am not familiar with JSP syntax which is why i am unable to convert the logic my self.

        Does anybody have the microsoft java language conversion assistant tool to convert the above code for me? I know its available to download for free but i need visual studio 2005 package to run it!
        Oh, so you don't want to write the code but want to use a software package to convert the codes? Maybe someone else will help you then. I prefer helping those actually writing the code.

        Comment

        Working...