Accessing a array through a servlet and outputting info in a JSP?

I have researched and have not come up with any examples and no answer as to how to do this. Please help... The molecular2.java does all the computation. I will only include a snippet of it.
This file is like this because I needed to return multiple items and could not find another way to do it.
public String getResult(String mw)
if(overallcount == 1.0)
String overallcount 4 = String.valueOf(overallcount1);
return overallcount4;
else
String overallcount3 = String.valueOf(overallcount);
for(int i=0; i<j; i++)
if(coeff[i] != 0.0)
finalcoeff[i] = ((coeff/overallcount)*100);
} // keep in mind that and array called element[], has already been filled
return overallcount3;
} public String getResult(String mw)
if(overallcount == 1.0)
String overallcount 4 = String.valueOf(overallcount1);
return overallcount4;
else
String overallcount3 = String.valueOf(overallcount);
for(int i=0; i<j; i++)
if(coeff[i] != 0.0)
finalcoeff[i] = ((coeff[i]/overallcount)*100);
} // keep in mind that and array called element[], has already been filled
return overallcount3;
} Help with Code Tags (Toggle Plain Text) public String getResult(String mw)
if(overallcount == 1.0)
String overallcount 4 = String.valueOf(overallcount1);
return overallcount4;
else
String overallcount3 = String.valueOf(overallcount);
for(int i=0; i<j; i++)
{if(coeff[i] != 0.0){
finalcoeff[i] = ((coeff[i]/overallcount)*100);
} // keep in mind that and array called element[], has already been filled}
return overallcount3;}
} public String getResult(String mw){
if(overallcount == 1.0)
String overallcount 4 = String.valueOf(overallcount1);
return overallcount4;
else
String overallcount3 = String.valueOf(overallcount);
for(int i=0; i<j; i++)
if(coeff[i] != 0.0)
finalcoeff[i] = ((coeff[i]/overallcount)*100);
} // keep in mind that and array called element[], has already been filled
return overallcount3;
I want to pass the information hat I get here to a servlet that looks like this and is called MoleCalc.javapublic class Molecalc extends javax.servlet.http.HTTPServlet implements javax.servlet.Servlet {
protected void doGet (...)
RequestDispatcher disp = request.getRequestDispatcher("jsp/Calculators/MoleCalc.jsp");
if((request.getParameter("submit")==null) || (request.getParameter("submit").length() == 0))
{//do nothing
else //user hits submit button
if((request.getParameter("mole") != null) && (request.getParameter("mole").length() > 0))
String moleS = request.getParameter("mole");
String moleStr = "";
String overallcount = "";
try
overallcount = Molecular2.getResult(moleS);
if(overallcount == "1.0")
request.setAttribute("mole","");
request.setAttribute("moleformula","");
request.setAttribute("errormsg", "Did no t enter a proper equation");
}public class Molecalc extends javax.servlet.http.HTTPServlet implements javax.servlet.Servlet {
protected void doGet (...)
RequestDispatcher disp = request.getRequestDispatcher("jsp/Calculators/MoleCalc.jsp");
if((request.getParameter("submit")==null) || (request.getParameter("submit").length() == 0))
{//do nothing
else //user hits submit button
if((request.getParameter("mole") != null) && (request.getParameter("mole").length() > 0))
String moleS = request.getParameter("mole");
String moleStr = "";
String overallcount = "";
try
overallcount = Molecular2.getResult(moleS);
if(overallcount == "1.0")
request.setAttribute("mole","");
request.setAttribute("moleformula","");
request.setAttribute("errormsg", "Did no t enter a proper equation");
}Could someone please tell me how to implement the array into this code? I have tried everything that I can imagine but it is not working.
Any help would be great.... Thanks!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Also....
I am figuring that for the jsp, which is MoleCalc.jsp, that I would just do a couple of foreach statements.
<form name = "moleformula" method="get" action="MoleCalc.java" onsubmit = "return vInputMoleformula(this);">
<h3>enter the Molecular Formula: </h3>
<td><input type="text" name="mole" id="mole" value="" maxlength="10" size="10"/> Molecular Formula </td>
<input class="submitButton" type="submit" value="Compute" name="submit" /> <br />
<h2> Molecular Weight = <c:out value="${moleformula}"/> g.</h2><br/>
<br> The formula entered was: <c:out value="${mole}"/><br/>
<h2><font color=red><c:out value="${errormsg}"/></font></h2><br/></form></div><form name = "moleformula" method="get" action="MoleCalc.java" onsubmit = "return vInputMoleformula(this);">
<h3>enter the Molecular Formula: </h3>
<td><input type="text" name="mole" id="mole" value="" maxlength="10" size="10"/> Molecular Formula </td>
<input class="submitButton" type="submit" value="Compute" name="submit" /> <br />
<h2> Molecular Weight = <c:out value="${moleformula}"/> g.</h2><br/>
<br> The formula entered was: <c:out value="${mole}"/><br/>
<h2><font color=red><c:out value="${errormsg}"/></font></h2><br/></form></div>

Similar Messages

  • I cant access my facebook through my iphone and ipad but i can access it through my friend's laptop

    i cant access my facebook through my iphone and ipad but i can access it through my friend's laptop

    Facebook has a feature that requires you to authorise a new device, which could be causing an issue. Check your account settings when you're signed in on the computer, and see if it has anything along the lines of 'App Passwords'

  • How to capture path and file info in a JSP?

    Hi, I am developing an JSP in which I am trying to capture the path and file name that I can then write into a database entry.
    For example in MS word when you do file > open a box pops up that you can navigate to the required folder and then click on the file you wish to open.
    I would like to do something like that usign JSP.
    Is this possible?
    If so is there a particular java package I need to import in my JSP and what class would I use to add the file box.
    I am thinking that I would put a button in the JSP which the user clicks on to open the box. When they select the required file and click OK somehow my JSP then captures that path/file name and I can use it in an SQL statement to write to the database.
    Any suggestion would be great thanks.
    Jason.

    All you want is to upload a file from the client to the server, right?
    Google around using keywords jsp+file+upload and you'll get lot of results [1]. The Apache Commons FileUpload [2] is a commonly used one.
    [1] http://www.google.com/search?q=jsp+file+upload
    [2] http://commons.apache.org/fileupload/

  • Grabbing numbers from an array of type double and outputting them into a text file

    In a program im creating i need to save some coordinates of a micropositioner i have into a text file,
    I have the coordinates saved into an array that has 6 digits of precision (6 places after the decimal point).
    I use the number to string conversion and wire that into the write to text file function in labview.  When i open the file
    the numbers that are only displayed are the ones to the left of the decimal point.  I know the number to decimal string function
    rounds the values so if i were to input 3.111111 it would only output the string "3" instead of "3.111111" . 
    So to get all the digits onto the file without rounding i multiplied the number by 10^6 but the decimal point will be lost at that point.
    Is there anyway i can convert numbers into strings without labview rounding to the nearest whole number also without having to multiply by 10^6 and without having to expect the user to know that the coordinates saved in a file are multiplied by an order of magnitude of a million ? 

    ed oh i guess i just missed that function on the pallete after i saw that the function went from number to hex, octal, etc. i assumed that the rest on that row would be some sort of conversion to a different base number, haha thanks.

  • Maintaining Sessions through Multiple Servlets and Contexts

    Hi,
    I have a webapplication that works like this:
    * User connects to a login servlet on HTTPS
    * Users information is authenticated on HTTPS
    * An object is stored in the session for other servlets to validate the users access
    * Authenticated users are forwarded to an HTTP page where the session is used to make sure they were granted access
    My problem is this....Since I create the session in an HTTPS context, when I am in the HTTP context, I am unable to access the session and constantly get NULL. Is there any way that I can access the session from an HTTP context?

    What you can do is, just login using HTTPS and switch over to HTTP
    and then store data in session.That is true, but what I want in the session is basically a flag on whether or not the user was granted access. I would much rather set all that up on the secure line, and then just access it from the unsecure ones...
    For example, you are creating session using the
    http://testdev:port/index.jsp page.
    If access the same page(with hostname)
    http://10.300.20.18:8080/index.jsp, you can't get the session even
    though both are same web server and same web application. Because the
    browser treats it different sessionI think if you use my above solution with the explicit passing of the jsessionid, you can move from one domain to another and still maintain session. Not positive on that though...

  • Access laptop internet through bluetooth ?and...

    I have a laptop which has a datacard on another network cause the area im in doesnt have att coverage for my iphone.
    what i would like to know is if its possible to connect my iphone to use my laptops datacard internet through a bluetooth connection so i can use apps that need net
    or how to setup a network for it through the usb or would anyone know if my hp mini netbook can make a wifi network or would i need an external router?
    also when is apple gonna set up a sever for sending push notifications through internet connection? like when my phone doesnt have coverage but does have wifi connection. or is that in the vpn connection can i set that up to get that?

    The answer to your first question is no.
    If you have a computer with a wireless/wi-fi card that has an internet connection via Ethernet, you can create an ad-hoc wireless network with the computer turning the computer into a wireless router of sorts sharing the internet via Ethernet with another computer with a wireless card or with the iPhone.
    I'm not sure if the same is possible with an internet connection with a data card.
    Apple has already set up a server for push notifications for use with a 3rd party app that provides/supports push notification. It is up to the app developer for an app to make use of this via an internet with the cellular network or via wi-fi.

  • I signed up for iTunes Match so I could access my music through my iPad and the cloud without actually downloading the songs.  I have noticed that when ever I play a song on my iPad, it seems to download the song to my iPad, and I can't delete it.?

    How do I keep these songs from permanetly downloading to my iPad?

    Hi,
    Playing song are put into a temporary cache.
    Go to settings > general >usage > storage > Music. Delete from here.
    Jim

  • Servlet and Database Connectivity

    Hi,
    I have got a basic question. I am connecting to a database through a servlet and displaying a table. What I need to do is have three buttons at the bottom of the table like "ADD", "DELETE" "MODIFY". I am wondering how I can add buttons to the HTML page through the servlet, select a row and click on one of the buttons to MODIFY/DELETE and how to capture the actions of each button when clicked like when "ADD" button is clicked it should pass control to a servlet "add.java". If i plan to include a javascript how can i call from the servlet, is there a way. If anyone could throw me some light or atleast point me in the right direction that would be great.
    Thanks
    Chak

    you can even use buttons!
    HTML:
    <input type="submit" name="add" value="Add">
    <input type="submit" name="modify" value="Modify">
    <input type="submit" name="delete" value="Delete">
    Servlet:
    String addButton = req.getParameter("add");
    String modifyButton = req.getParameter("modify");
    String deleteButton = req.getParameter("delete");
    So when the add-Button is clicked, addButton equals to "add", modifyButton==null and deleteButton==null, and vice versa

  • I am not able to access my photos through the photo application... when I click on the photo app, I can see the camera roll but a transparent album screen is over it and I cannot click on the photos to see it... can any one please help ???

    I am not able to access my photos through the photo application... when I click on the photo app, I can see the camera roll, but a transparent "album" screen is over it and I cannot click on the photos to see it... can any one please help ???

    Known bug.  Quit the Camera App, double-tap the home key and delete Camera from the recent apps bar. Fire it up again, should be good.

  • How to call a jsp file from an servlet and access the jsp file objects??

    Hi everybody
    I have an jsp file where it contains a vector object with some data and I have a servlet that needs to access this vector object . How can my servlet call for this jsp page and get the vector object. ?
    then an applet will be calling this servlet to get some other object created with the data contained within this vector object...so each time Applet ask the servlet for the object the servlet need to call for this jsp page somehow
    My main question is the communication servlet-jsp
    please if u have any clue I will appreciate it
    thanks

    Hi
    There are several ways to share objects between JSPs/Servlets.
    You can share objects by putting them in the request-in which case the objects lifetime is limited by that of the request, Another way is to store them in the session, againg the lifetime is limited by the lifetime of the session. To have objects that have to persistent over the application life-span use the servletContext to store the objects.
    Any good tutorial should help you get started. Please see the link below for a tutorial on Servlets/JSPs
    Note: Local variables in the JSP cannot be shared with other components as their scope is limited to that particular Page/Servlet.
    Link: http://java.sun.com/docs/books/tutorial/servlets/
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc
    http://www.sun.com/developers/support

  • I have a Mac computer and am trying to use a Photoshop CS4 program, but after accessing my desktop files through Adobe Bridge and clicking twice on any of the pictures to get into Photoshop,  instead of entering photoshop I get an enlarged version of the

    I have a Mac computer and am trying to use a Photoshop CS4 program, but after accessing my desktop files through Adobe Bridge and clicking twice on any of the pictures to get into Photoshop, instead of entering photoshop, I get on the lefthand side an enlarged version of the picture with red, yellow and green buttons on top. Any suggestions on what is wrong, or what can be corrected ?

    And there is the problem. Your pictures are opening up in Mac's own Preview app.
    Do you want all your jpegs to open in Photoshop, or only when you are in Bridge?
    Selecting a program to open a certain file is called: File Type Association.
    You can choose this at the MacOS level or the Bridge level.
    Here's how to do both:
    Either MacOS or Bridge has the wrong app associated with the jpeg. Let's start with MacOS
    Close Bridge and Preview. Select one of your jpegs, and press Cmd i, That will bring up the file info window.
    Go down to the "Open with" section of File Info.
    Choose Photoshop CS4 and click on the Change All... button to apply this choice to every jpeg on your Mac.
    Then open Bridge and see if double-clicking opens it in Photoshop.
    Now that means all jpegs on your Mac will open in Photoshop.  Maybe you don't want that.
    You can set your jpegs to open in Preview when Bridge is closed.
    When you open Bridge, there is Preferences > File Type Associations where you can direct Bridge to open the jpegs in Photoshop when you are viewing in Bridge.

  • Hi Folks,  I am using FCPX 10.0.8 on a MPB 10.8.2 with a multi in/out audio device RME Fireface 400.  I recorded a timecode track through in 11 and routed it to out 3.  Initially it worked, although it did also play timecode through the main outputs 1

    Hi Folks,
    I am using FCPX 10.0.8 on a MPB 10.8.2 with a multi in/out audio device RME Fireface 400.
    I recorded a timecode track through in 11 and routed it to out 3.
    Initially it worked, although it did also play timecode through the main outputs 1&2 !!!
    Now it has stopped playing TC through output 3.
    Is FCPX capable of working with professional audio?
    Regards
    Donagh Long.

    You welcome

  • Read from .txt file and output the content as two arrays

    I am using the contoured move to control the x-y stage. The trajectory datas for x and y axis are generated using my interpolation program and it is stored in a .txt file as two columns. What I want to do is read .txt file and output the content of this file as two arrays. Is there anyone has any ideas? Thanks, the .txt file is attached.
    Attachments:
    R.75.txt ‏172 KB

    Hi Awen,
    This is quite easy to do, you can merely use the "read from spreadsheet file" function to get a 2D array (2 columns and n rows) and then use the index array function to get whatever row/colums you want..
    Hope the attached VI helps you
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"
    Attachments:
    read sprdsheet file.vi ‏27 KB

  • How to send array of bytes to a servlet and store it in a file

    Hi,
    How to send array of bytes to a servlet and store it in a file.
    I am new to Servlets. if possible for any one, please provide the code.
    Thanks,
    cmbl

    Through HTTP this is only possible with a POST request of which the encoding type is set to multipart/form-data. You can use Apache Commons FileUpload to parse such a multipart form data request into useable elements. From the other side (the client) you can use a HTML <input type="file"> element or a Java class with Apache Commons PostMethod API.
    You may find this article useful: http://balusc.blogspot.com/2007/11/multipartfilter.html

  • I have a small production client looking to run 1 workstation running Mac Lion 10.7.3 and two work stations running Windows7 64 bit. They will all be talking to the same storage array through 8Gb FC. What is there most cost effective way to do this?

    I have a small production client looking to run 1 workstation running Mac Lion 10.7.3 and two work stations running Windows7 64 bit. They will all be talking to the same storage array through 8Gb FC. What is there most cost effective way to do this?

    Thank you for your help.
    The client has already made the jump to 8Gb including HBA's, switch and RAID Storage.
    The other question will be if they need a seperate Mac Server to run the Meta Data or are they able to use the current Mac they are running to do this?
    The Mac is a 201073 model they say with 12 Dual Core 2.66Mhz processors and 16 GB of Memory. This system is currently doing rendering. It has the XSAN Client but I understand for the solution to work they need to also run XSAN Server on a MDC.

Maybe you are looking for

  • PR error while creating

    Dear Sir, I am creatin Service PR while saving its showing an error "Slow moving item PR not allowed" what i will do to resolve it...

  • CC 2014 Extremely slow, unusable

    Here's my specs: PC Laptop running Win 8.1 Intel i7 2GHz 8GB RAM This computer is brand new, as in just bought today. Second app installed after a virus scanner was Dreamweaver CC 2014. I cannot use it to save my life. When I am in Code view (the mai

  • Oracle apps workflows

    Hi Team, sql query for Finding the  Workflow name, type, product, creation & update dates order by Product in oracle apps Thanks, chandu

  • Report 10g return status to Unix

    Hi, Could any one explain what will be the status of Report 10g to unix on completion. (such as 0 for success or other values for failure). Thanks

  • Mail fails to load

    Imac was in storage from june to December. I have updated software. Mail now fails to load. First got the v4.5 mail message and found the 'fix' and have tried that 'twice' loaded the combo 10.6.8 v1.1 and the security 2012-004 snow leopard. checked t