I really want to thank you so much for this amazing response :) it helped 
me a lot,but i still have a problem ! when i change my servlet to this :
package de.tuberlin.cit.tublr;

import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

import java.io.IOException;
import java.util.Date;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
public class TUBlrServlet extends HttpServlet 
{

private static final long serialVersionUID = 3218329961842485677L;


private BlobstoreService blobstoreService = 
BlobstoreServiceFactory.getBlobstoreService();

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {

resp.sendRedirect("/tublr.jsp");
 BlobKey blobKey = new BlobKey(req.getParameter("blob-key"));
        blobstoreService.serve(blobKey, resp);
}

public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
 Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
    BlobKey blobKey = blobs.get("post_image");

    if (blobKey == null) {
        resp.sendRedirect("/");
    } else {
        resp.sendRedirect("/serve?blob-key=" + blobKey.getKeyString());
    } 
}
}



 and jsp to this :
<%@page language="java" contentType="text/html; charset=UTF-8" 
pageEncoding="UTF-8"%>
<%@ page 
import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %>
<%@ page import="com.google.appengine.api.blobstore.BlobstoreService" %>
<%
    BlobstoreService blobstoreService = 
BlobstoreServiceFactory.getBlobstoreService();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd";>
       
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
  <title>cc-gXX-tublr</title>
  <link href="default.css" rel="stylesheet" type="text/css" 
media="all"></link>
</head>
 
<body>
<div id="header-wrap"> 
<div id="header">
<img src="images/tublr.png" alt="tublr"></img> 
<h3>A photo-sharing service by TU-Berlin!</h3> 
</div>
</div>
 <div class="post_form_wrap">
<form class="post_form" action="<%= 
blobstoreService.createUploadUrl("/TUBlrServlet") %>"
      method="post" enctype="multipart/form-data">
      
<h3>Post a new image:</h3>
Image: <input name="post_image" type="file" size="35" 
maxlength="5000000"/><br/>
Message [optional]: <input name="post_text" type="text" size="30" 
maxlength="30"/>
<p><input type="submit" value="Submit"/></p>
<input type="hidden" name="type" value="post"/>
</form>
<hr/>
</div>
 <div id="content-wrapper">
<div class="post">
<div class="post_data">
<div class="post_image">
<a href="FIXME"><img src="FIXME"/></a>
</div>
<h4>Posted on FIXME:</h4>
<div class="post_text">FIXME</div>
</div>
 <div class="comment_data">
<div class="comment_image">
<a href="FIXME"><img src="FIXME"/></a>
</div>
<h4>Comment posted on FIXME:</h4>
<div class="comment_text">FIXME</div> 
</div> 
<div class="comment_form">
<form action="FIXME" method="post" 
      enctype="multipart/form-data">
Image: <input name="comment_image" type="file" size="35" 
maxlength="5000000"/><br/>
Message [optional]: <input name="comment_text" type="text" size="30" 
maxlength="30"/><br/>
<input type="submit" value="Post Comment!"/>
<input type="hidden" name="type" value="comment"/>
</form>
</div>
</div>
<hr/>
</div>
  
</body>
</html>


its doesnt work ! it show me a 404 page not found
Can you help me please to find my mistakes ?

Le mercredi 26 juin 2013 19:34:13 UTC+2, Vinny P a écrit :
>
> Hello Ben,
>  
> On Wed, Jun 26, 2013 at 12:10 PM, ben <raed...@gmail.com <javascript:>>wrote:
>>
>> I'm trying to create a social web application with JAVA eclipse and 
>> Google app engine that offers its users to share and discuss photos. It 
>> should consist of a single web page, that displays posts and the comments 
>> to each post. Each comment belongs to exactly one post and therefore each 
>> post has a (possibly empty) list of comments. i still have many problems 
>> with displaying posts and saving comments with App Engine data store (HRD) 
>> !! 
>>
>> Could you please give some suggestions, how can I post image and save 
>> comment using HRD ?
>>
>  
> It looks like you're trying to create an imageboard-style ( 
> http://en.wikipedia.org/wiki/Imageboard ) web application, correct? If 
> so, you don't need to code it by yourself; there are many open source 
> implementations you could use such as TinyBoard ( http://tinyboard.org/ ). 
>
>   
> If you really want to code this by yourself, then you can do so easily 
> with App Engine. You can upload an image by using the Blobstore (example 
> source code here: 
> https://developers.google.com/appengine/docs/java/blobstore/#Uploading_a_Blob 
> ). 
> In regards to the comments, you'll need to retrieve the contents of the 
> user's message using standard parameter retrieval: String post_text = 
> req.getParameter("post_text"); 
>   
> Then you can store it in the datastore by creating an entity, storing the 
> post comment as a property, then saving it to the datastore. Here's a code 
> example: 
> https://developers.google.com/appengine/docs/java/datastore/entities#Creating_an_Entity
>   
> -----------------
> -Vinny P
> Technology & Media Advisor
> Chicago, IL
>
> App Engine Code Samples: http://www.learntogoogleit.com
>   
>

-- 
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/groups/opt_out.


Reply via email to