這是我讀取網頁的位置<html>
<body>
<form method=get action="/myapp/Hello">
請輸入圖片的位置:
<input type=text name="place"><p>
<input type=submit>
</form>
</body>
</html>下面是JAVA程式我不知道該怎麼把它改成Servlet的形式import java.io.*;import java.util.*;
import java.text.*;
//import java.awt.*;
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 {
我想將這行c://dog.jpg的檔案位置這是固定的,我想改成網頁上的place的值
有人知道我該要怎麼做嗎? 如果能的話請可以修改給我看嗎? InputStream fip = new BufferedInputStream(new FileInputStream("c://dog.jpg"));
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);
Entry e;
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);
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));
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();
OutputStream out = new BufferedOutputStream(new FileOutputStream("c://w.jpg"));
llj.xferInfo(null, out, LLJTran.REPLACE, LLJTran.REPLACE); fip.close();
out.close(); llj.freeMemory();
}
}下面這是最簡單的SERVLET傳值
我不知道要怎麼將寫好的JAVAT程式改成下面的形式
有人能修改給我看要怎麼把上面的SetGpsInfo.java轉成 servlet的形式來讓網頁讀取import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;public class Hello extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html; charset=big5");
request.setCharacterEncoding("big5"); PrintWriter out = response.getWriter(); String UserID = request.getParameter("place");
out.println("<html><body>");
out.println("您好, " + UserID);
out.println("</body></html>");
} public String getServletInfo() {
return "A servlet that knows the user ID";
}
}
<body>
<form method=get action="/myapp/Hello">
請輸入圖片的位置:
<input type=text name="place"><p>
<input type=submit>
</form>
</body>
</html>下面是JAVA程式我不知道該怎麼把它改成Servlet的形式import java.io.*;import java.util.*;
import java.text.*;
//import java.awt.*;
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 {
我想將這行c://dog.jpg的檔案位置這是固定的,我想改成網頁上的place的值
有人知道我該要怎麼做嗎? 如果能的話請可以修改給我看嗎? InputStream fip = new BufferedInputStream(new FileInputStream("c://dog.jpg"));
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);
Entry e;
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);
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));
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();
OutputStream out = new BufferedOutputStream(new FileOutputStream("c://w.jpg"));
llj.xferInfo(null, out, LLJTran.REPLACE, LLJTran.REPLACE); fip.close();
out.close(); llj.freeMemory();
}
}下面這是最簡單的SERVLET傳值
我不知道要怎麼將寫好的JAVAT程式改成下面的形式
有人能修改給我看要怎麼把上面的SetGpsInfo.java轉成 servlet的形式來讓網頁讀取import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;public class Hello extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html; charset=big5");
request.setCharacterEncoding("big5"); PrintWriter out = response.getWriter(); String UserID = request.getParameter("place");
out.println("<html><body>");
out.println("您好, " + UserID);
out.println("</body></html>");
} public String getServletInfo() {
return "A servlet that knows the user ID";
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货