要怎麼做出
java程式可以獲取網頁的值來當作程式中的檔案讀取位置
下面是我的網頁
我先將from1丟到b.jsp
後來在獲取他的值
後面我把這個值變為path String path = (String) request.getParameter("path");
而這個path就是我java程式內容的讀取檔案位置
後面的問題就是我利用servlet來執行JAVA檔而這個java程式沒有指定他讀取的檔案位置
我需要在程式中修改什麼才能獲取b.jsp的path這個值來當作java讀檔的執行位置
a.jsp
<script language="JavaScript" type="text/JavaScript">
function doPost() {
form1.action = "b.jsp";
form1.submit();
} <form name="form1" method="post">
<input name="path" type="text" id="path" value="">
<input type="button" name="button1" value="提交" onClick="doPost();"
</form>
-----------------------------------------------------------------------------------
b.jsp
<%@ page contentType="text/html; charset=GBK" language="java"%>
<%
String path = (String) request.getParameter("path");
<%@ page language="java" contentType="text/html; charset=Big5" import="JBeans.gps"%>
<BODY>
<jsp:useBean id="gps" scope="session" class="JBeans.gps"/>
</BODY>
</HTML>
%>
下面為JAVA檔
在一開始的時候我有讀取檔案
InputStream fip = new BufferedInputStream(new FileInputStream(args[0]));
我要怎麼修改 才能在JAVA程式中獲得網頁的path值 來取代arg[0]來當作他的位置 import java.io.*;
import java.util.*;
import java.text.*;
import java.awt.image.*;
import java.awt.geom.AffineTransform;
import javax.imageio.*;
import javax.imageio.stream.*;import mediautil.gen.*;
import mediautil.gen.directio.*;
import mediautil.image.*;
import mediautil.image.jpeg.*;
public class SetGpsInfo { public static void main(String[] args) throws Exception { InputStream fip = new BufferedInputStream(new FileInputStream(args[0]));
LLJTran llj = new LLJTran(fip);
try {
llj.read(LLJTran.READ_INFO, true);
} catch (LLJTranException e) {
e.printStackTrace();
} AbstractImageInfo imageInfo = llj.getImageInfo(); if(! (imageInfo instanceof Exif))
{
System.out.println("Sorry Image Does not have Exif. Exitting." + imageInfo);
System.exit(1);
} Exif exif = (Exif) imageInfo;
IFD mainIfd = exif.getIFDs()[0];
IFD gpsIfd = mainIfd.getIFD(Exif.GPSINFO); if(gpsIfd == null)
{
System.out.println("Gps IFD not found adding..");
gpsIfd = new IFD(Exif.GPSINFO, Exif.LONG);
mainIfd.addIFD(gpsIfd);
} /* Set some values directly to gps IFD */
Entry e; // Set Latitude
e = new Entry(Exif.ASCII);
e.setValue(0, 'N');
gpsIfd.setEntry(new Integer(Exif.GPSLatitudeRef), 0, e);
e = new Entry(Exif.RATIONAL);
e.setValue(0, new Rational(45, 1));
e.setValue(1, new Rational(35, 1));
e.setValue(2, new Rational(25, 1));
gpsIfd.setEntry(new Integer(Exif.GPSLatitude), 0, e);
e = new Entry(Exif.BYTE); // Set Longitude
e = new Entry(Exif.ASCII);
e.setValue(0, 'E');
gpsIfd.setEntry(new Integer(Exif.GPSLongitudeRef), 0, e);
e = new Entry(Exif.RATIONAL);
e.setValue(0, new Rational(87, 1));
e.setValue(1, new Rational(40, 1));
e.setValue(2, new Rational(30, 1));
gpsIfd.setEntry(new Integer(Exif.GPSLongitude), 0, e);
e = new Entry(Exif.BYTE); e.setValue(0, new Integer(1)); // This picture is taken underwater :-)
// Use 0 if it is taken above sea
// level
gpsIfd.setEntry(new Integer(Exif.GPSAltitudeRef), 0, e);
e = new Entry(Exif.RATIONAL);
e.setValue(0, new Rational(100, 1));
gpsIfd.setEntry(new Integer(Exif.GPSAltitude), 0, e); llj.refreshAppx(); // Recreate Marker Data for changes done OutputStream out = new BufferedOutputStream(new FileOutputStream(args[1])); // Transfer remaining of image to output with new header.
llj.xferInfo(null, out, LLJTran.REPLACE, LLJTran.REPLACE); fip.close();
out.close(); llj.freeMemory();
}
}
java程式可以獲取網頁的值來當作程式中的檔案讀取位置
下面是我的網頁
我先將from1丟到b.jsp
後來在獲取他的值
後面我把這個值變為path String path = (String) request.getParameter("path");
而這個path就是我java程式內容的讀取檔案位置
後面的問題就是我利用servlet來執行JAVA檔而這個java程式沒有指定他讀取的檔案位置
我需要在程式中修改什麼才能獲取b.jsp的path這個值來當作java讀檔的執行位置
a.jsp
<script language="JavaScript" type="text/JavaScript">
function doPost() {
form1.action = "b.jsp";
form1.submit();
} <form name="form1" method="post">
<input name="path" type="text" id="path" value="">
<input type="button" name="button1" value="提交" onClick="doPost();"
</form>
-----------------------------------------------------------------------------------
b.jsp
<%@ page contentType="text/html; charset=GBK" language="java"%>
<%
String path = (String) request.getParameter("path");
<%@ page language="java" contentType="text/html; charset=Big5" import="JBeans.gps"%>
<BODY>
<jsp:useBean id="gps" scope="session" class="JBeans.gps"/>
</BODY>
</HTML>
%>
下面為JAVA檔
在一開始的時候我有讀取檔案
InputStream fip = new BufferedInputStream(new FileInputStream(args[0]));
我要怎麼修改 才能在JAVA程式中獲得網頁的path值 來取代arg[0]來當作他的位置 import java.io.*;
import java.util.*;
import java.text.*;
import java.awt.image.*;
import java.awt.geom.AffineTransform;
import javax.imageio.*;
import javax.imageio.stream.*;import mediautil.gen.*;
import mediautil.gen.directio.*;
import mediautil.image.*;
import mediautil.image.jpeg.*;
public class SetGpsInfo { public static void main(String[] args) throws Exception { InputStream fip = new BufferedInputStream(new FileInputStream(args[0]));
LLJTran llj = new LLJTran(fip);
try {
llj.read(LLJTran.READ_INFO, true);
} catch (LLJTranException e) {
e.printStackTrace();
} AbstractImageInfo imageInfo = llj.getImageInfo(); if(! (imageInfo instanceof Exif))
{
System.out.println("Sorry Image Does not have Exif. Exitting." + imageInfo);
System.exit(1);
} Exif exif = (Exif) imageInfo;
IFD mainIfd = exif.getIFDs()[0];
IFD gpsIfd = mainIfd.getIFD(Exif.GPSINFO); if(gpsIfd == null)
{
System.out.println("Gps IFD not found adding..");
gpsIfd = new IFD(Exif.GPSINFO, Exif.LONG);
mainIfd.addIFD(gpsIfd);
} /* Set some values directly to gps IFD */
Entry e; // Set Latitude
e = new Entry(Exif.ASCII);
e.setValue(0, 'N');
gpsIfd.setEntry(new Integer(Exif.GPSLatitudeRef), 0, e);
e = new Entry(Exif.RATIONAL);
e.setValue(0, new Rational(45, 1));
e.setValue(1, new Rational(35, 1));
e.setValue(2, new Rational(25, 1));
gpsIfd.setEntry(new Integer(Exif.GPSLatitude), 0, e);
e = new Entry(Exif.BYTE); // Set Longitude
e = new Entry(Exif.ASCII);
e.setValue(0, 'E');
gpsIfd.setEntry(new Integer(Exif.GPSLongitudeRef), 0, e);
e = new Entry(Exif.RATIONAL);
e.setValue(0, new Rational(87, 1));
e.setValue(1, new Rational(40, 1));
e.setValue(2, new Rational(30, 1));
gpsIfd.setEntry(new Integer(Exif.GPSLongitude), 0, e);
e = new Entry(Exif.BYTE); e.setValue(0, new Integer(1)); // This picture is taken underwater :-)
// Use 0 if it is taken above sea
// level
gpsIfd.setEntry(new Integer(Exif.GPSAltitudeRef), 0, e);
e = new Entry(Exif.RATIONAL);
e.setValue(0, new Rational(100, 1));
gpsIfd.setEntry(new Integer(Exif.GPSAltitude), 0, e); llj.refreshAppx(); // Recreate Marker Data for changes done OutputStream out = new BufferedOutputStream(new FileOutputStream(args[1])); // Transfer remaining of image to output with new header.
llj.xferInfo(null, out, LLJTran.REPLACE, LLJTran.REPLACE); fip.close();
out.close(); llj.freeMemory();
}
}
然后设置setParameter("path",值);试试。。
String path = form1.getParameterValue("path");
後面為form1.setParameter("path", "值");嗎
問題是值在jsp裡面有改為path可以直接打
("path", "path");嗎如果有知道或看過類似範例的能貼給我交我嗎