Hi All,

    I am using Eclipse to develope Java appengine application. I used 1.9.0 
SDK. If I upload files locally its working fine with this url 
localhost:8888 but I change the url by using *--address=192.168.1.103* it 
change the URL to

*http://localhost:8888/_ah/upload/ahRoZWxwZGVza2Fzc2V0c2VydmljZXIiCxIVX19CbG9iVXBsb2FkU2Vzc2lvbl9fGICAgICAgMkKDA*

then I change the localhost to 192.168.1.103 it show error like this 

*Error 405 HTTP method GET is not supported by this URL*

*My JSP Code:*





*<%@ page 
import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %><%@ 
page import="com.google.appengine.api.blobstore.BlobstoreService" 
%> <script><%BlobstoreService blobstoreService = 
BlobstoreServiceFactory.getBlobstoreService();%></script><html><head><title>Show
 
My Picture(s)</title></head><body><h2>Upload picture(s)</h2><form 
action="<%= blobstoreService.createUploadUrl("/attach") %>" method="post" 
enctype="multipart/form-data">To :<input type="text" id="to" name="to" 
/><br>Subject :<input type="text" id="subject" name="subject" /><br>Message 
:<input type="text" id="message" name="message"/><br><input type="file" 
name="myPics" multiple="multiple"/><input type="submit" 
value="Send"/></form></html>My web.xml*





*<?xml version="1.0" encoding="utf-8"?><web-app 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
 
version="2.5"><servlet> <servlet-name>AttachServlet</servlet-name> 
<servlet-class>com.sbt.has.servlet.AttachServlet</servlet-class></servlet><servlet-mapping>
 
<servlet-name>AttachServlet</servlet-name> 
<url-pattern>/attach</url-pattern></servlet-mapping> <welcome-file-list> 
<welcome-file>attach.jsp</welcome-file></welcome-file-list></web-app>My 
Servlet Code:*
package com.sbt.has.servlet;

import java.io.*;
import java.util.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.blobstore.BlobInfo;
import com.google.appengine.api.blobstore.BlobInfoFactory;
import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;

@SuppressWarnings("serial")
public class AttachServlet extends HttpServlet {

Long blobSize = null;

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String to = request.getParameter("to");
String subject = request.getParameter("subject");
String message = request.getParameter("message");

System.out.println("To" + to);
System.out.println("subject" + subject);
System.out.println("message" + message);

response.setContentType("text/html");
PrintWriter out = response.getWriter();
BlobstoreService blobstoreService = null;
blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
System.out.println("blobstoreService :" + blobstoreService);
BlobInfoFactory blobInfoFactory = new BlobInfoFactory();
String blobFilename = "";
String extension = "";
Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(request);
List<BlobKey> blobKeylst = new ArrayList<BlobKey>();
List<String> fileextension = new ArrayList<String>();
List<String> filename = new ArrayList<String>();
List<Long> filesize = new ArrayList<Long>();
try {
blobKeylst = blobs.get("myPics");
System.out.println("lst size" + blobKeylst.size());
for (int i = 0; i < blobKeylst.size(); i++) {
BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKeylst
.get(i));
blobFilename = blobInfo.getFilename();
blobSize = blobInfo.getSize();
filename.add(blobFilename);
filesize.add(blobSize);
}

for (int k = 0; k < filename.size(); k++) {
int extlen = filename.get(k).lastIndexOf('.');
System.out.println("Extlen :" + extlen);
if (extlen >= 0 && extlen < filename.get(k).length() - 1) {
extension = filename.get(k).substring(extlen).toLowerCase();
System.out.println("Extension : " + extension);
}
fileextension.add(extension);
}

for (int g = 0; g < fileextension.size(); g++) {
if ((fileextension.get(g).equals(".jpg"))
|| (fileextension.get(g).equals(".png"))
|| (fileextension.get(g).equals(".gif"))
|| (fileextension.get(g).equals(".bmp"))) {
if (filesize.get(g) <= 1048576) {
out.println("File size Valid");
} else {
out.println("File size should be less than or Equal to 1 MB");
break;
}
} else {
out.println("Can only upload .jpg,.png,.bmp,.gif files");
break;
}
}
System.out.println("List Ext :" + fileextension);
} catch (Exception e) {
e.printStackTrace();
System.out
.println("Document failed to POST, redirecting back to upload.");
response.sendRedirect("/index.jsp");
}

}
}


Please Help me to solve this issue

Thanks
A.Dias

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.

Reply via email to